Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Tests covering regression in given/for s.m.
  • Loading branch information
jnthn committed Apr 28, 2015
1 parent f3d73db commit f113f3f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion S04-statement-modifiers/for.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 25;
plan 26;

# L<S04/"Conditional statements"/Conditional statement modifiers work as in Perl 5>

Expand Down Expand Up @@ -138,4 +138,11 @@ is ((sub r { "OH HAI" })() for 5), "OH HAI", 'Anon sub in statement modifier for
is $a, '12', 'Correct $_ in try block in statement-modifying for';
}

{
# Covers a bug where the block to first got compiled in the 'for' thunk
my @a;
for ^2 -> \c { 1 for first { @a.push(c); 0 }, ^2; };
is @a, (0, 0, 1, 1), 'for thunk does not mess up statement modifier closures';
}

# vim: ft=perl6
9 changes: 8 additions & 1 deletion S04-statement-modifiers/given.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 10;
plan 11;

# L<S04/"Conditional statements"/Conditional statement modifiers work as in Perl 5>

Expand Down Expand Up @@ -68,4 +68,11 @@ plan 10;
is $a, 42, 'given modifier with placeholder block runs block with correct arg';
}

{
# Covers a bug where the block to first got compiled in the 'given' thunk
my @a;
for ^2 -> \c { 1 given first { @a.push(c); 0 }, ^2; };
is @a, (0, 0, 1, 1), 'given thunk does not mess up statement modifier closures';
}

# vim: ft=perl6

0 comments on commit f113f3f

Please sign in to comment.