Permalink
Browse files

[t] moved chained.t to spec/, don't rely on the exact output of .perl

and changed dies_ok to eval_dies_ok


git-svn-id: http://svn.pugscode.org/pugs@22122 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
1 parent 2b21ee3 commit 939b33eb9816326073783f96f11f0989d4df49a4 moritz committed Sep 3, 2008
Showing with 38 additions and 0 deletions.
  1. +38 −0 S03-operators/chained-declarators.t
@@ -0,0 +1,38 @@
+use v6;
+use Test;
+
+# L<S03/"Declarators">
+# This section describes declarators like my, our, etc
+# Note that the usage of declarators on the RHS is not spec'ed yet,
+# but works like Perl 5. Also note that the list if declarators here
+# does not match the list described in the referenced specs.
+
+plan 6;
+
+# sanity: declarations and very simple use (scoping tests come later)
+# we take care to use different names to avoid other *kinds* of insanity.
+
+is((try { my $a1 = my $b1 = 42; $b1++; "$a1, $b1" }), '42, 43', "chained my");
+is((try { my $a2 = our $b2 = 42; $b2++; "$a2, $b2" }), '42, 43', "chained my, our");
+is((try { my $a4 = constant $b4 = 42; "$a4, $b4" }), '42, 42', "chained my, constant");
+is((try { my $a5 = state $b5 = 42; $b5++; "$a5, $b5" }), '42, 43', "chained my, state");
+
+# scoping
+
+#XXX is this one correct? Is $sb1 even known outside the inner block?
+is((try {
+ my $sa1 = 10;
+ {
+ my $sa1 = our $sb1 = 42;
+ }
+ "$sa1, $sb1";
+ }), '10, 42', "scoping my, our");
+
+eval_dies_ok '
+ {
+ our $sa2 = my $sb2 = 42;
+ }
+ ($sa2, $sb2);
+ ', "scoping our, my ('our' doesn't leak)";
+
+# XXX: add more!

0 comments on commit 939b33e

Please sign in to comment.