Permalink
Browse files

[S04-statements/do.t] Add tests for do with loop labels, and fudge fo…

…r Niecza
  • Loading branch information...
1 parent b132f85 commit 01cf81b6b250a4f8b2e6dfdea2180836bf8485cb @sorear sorear committed Jun 29, 2011
Showing with 10 additions and 1 deletion.
  1. +10 −1 S04-statements/do.t
View
@@ -2,7 +2,7 @@ use v6;
use Test;
-plan 24;
+plan 27;
# L<S04/The do-once loop/"can't" put "statement modifier">
# Note in accordance with STD, conditionals are OK, loops are not.
@@ -41,6 +41,7 @@ eval_lives_ok 'my $i = 1; do { $i++ } if $i;',
any branch, the return value is undefined in item context and ()
in list context.
=end comment
+#?niecza skip 'Nil'
{
my $x = do if 0 { 1 } elsif 0 { 2 };
ok !$x.defined, 'when if does not execute any branch, return undefined';
@@ -91,6 +92,14 @@ eval_lives_ok 'my $i = 1; do { $i++ } if $i;',
is $i, 1, "'next' works in 'do' block";
}
+#?rakudo 3 skip "labels"
+is eval('my $i; A: do { $i++; last A; $i-- }; $i'), 1,
+ "'last' works with label";
+is eval('my $i; A: do { $i++; next A; $i-- }; $i'), 1,
+ "'next' works with label";
+is eval('my $i; A: do { $i++; redo A until $i == 5; $i-- }; $i'), 4,
+ "'redo' works with label";
+
#?rakudo skip 'last not implemented'
{
is eval('

0 comments on commit 01cf81b

Please sign in to comment.