Hi all,

I was hoping I had a bit more time tonight to work on tests, but house-hacking
projects took precedence.  Attached is a patch to t/op/pair.t to add some
additional tests to make sure values of numbers and pairs can be handled as
well as using a pair as a key for a pair. 

The test script as written will fail since the => operator can't handle
syntax like "1 => 2 => 3 => 4".  If you'd rather skip this test for now, 
comment it out or delete it as you prefer.

Steve Peters
[EMAIL PROTECTED]
--- old/pugs/t/op/pair.t        2005-02-21 21:22:32.727286237 -0600
+++ pugs/t/op/pair.t    2005-02-21 21:39:45.759396111 -0600
@@ -1,22 +1,42 @@
 use v6;
 
-say "1..5";
+say "1..13";
 
-my $pair1 = 'foo' => 'bar';
+my $pair = 'foo' => 'bar';
+if (ref $pair eq 'Pair') { say "ok 1" } else { say "not ok 1" }
 
-my $foo = $pair1.key;
-my $bar = $pair1.value;
+my $foo = $pair.key;
+my $bar = $pair.value;
 
-if ($foo eq 'foo') { say "ok 1" } else { say "not ok 1" }
-if ($bar eq 'bar') { say "ok 2" } else { say "not ok 2" }
+if ($foo eq 'foo') { say "ok 2" } else { say "not ok 2" }
+if ($bar eq 'bar') { say "ok 3" } else { say "not ok 3" }
 
-my @pair1 = $pair1.kv;
+my @pair1 = $pair.kv;
 
-if (@pair1[0] eq 'foo') { say "ok 3" } else { say "not ok 3" }
-if (@pair1[1] eq 'bar') { say "ok 4" } else { say "not ok 4" }
+if (@pair1[0] eq 'foo') { say "ok 4" } else { say "not ok 4" }
+if (@pair1[1] eq 'bar') { say "ok 5" } else { say "not ok 5" }
 
 my $quux = eval '(quux => "xyzzy").key';
 
-if ($quux eq 'quux') { say "ok 5 # TODO => lhs quotes" } else { say "not ok 5 
# TODO => lhs quotes" }
+if ($quux eq 'quux') { say "ok 6 # TODO => lhs quotes" } else { say "not ok 6 
# TODO => lhs quotes" }
 
+#Pair with a numeric value
+my $pair = 'foo' => 2;
+if (ref $pair eq 'Pair') { say "ok 7" } else { say "not ok 7" }
+my $two = $pair.value;
+if ($two == 2) { say "ok 9" } else { say "not ok 9" };
+
+#Pair with a Pair value
+my $pair = "foo" => ("bar" => "baz");
+if (ref $pair eq 'Pair') { say "ok 10" } else { say "not ok 10" }
+my $pair2 = $pair.value;
+if (ref $pair2 eq 'Pair') { say "ok 11" } else { say "not ok 11" }
+
+#Pair with a Pair key
+$pair = ("foo" => "bar") => "baz";
+if (ref $pair eq 'Pair') { say "ok 12" } else { say "not ok 12" }
+my $key = $pair.key;
+if (ref $key eq 'Pair') { say "ok 13" } else { say "not ok 13" }
 
+#Pair list a la http://www.nntp.perl.org/group/perl.perl6.language/19360
+my $list = 1 => 2 => 3 => 4;

Reply via email to