Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Tests for block s.m. given/if/unless.
Includes a test for RT #78142.
  • Loading branch information
jnthn committed Apr 28, 2015
1 parent b1648de commit 8ab25b4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
14 changes: 13 additions & 1 deletion S04-statement-modifiers/given.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 8;
plan 10;

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

Expand Down Expand Up @@ -56,4 +56,16 @@ plan 8;
is $a, 'many pelmeni', 'Correct $_ in try block in statement-modifying given';
}

{
my $a;
{ $a = $^x } given 69;
is $a, 69, 'given modifier with $_-using block runs block with correct arg';
}

{
my $a;
{ $a = $^x } given 42;
is $a, 42, 'given modifier with placeholder block runs block with correct arg';
}

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

use Test;

plan 11;
plan 13;

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

Expand Down Expand Up @@ -72,4 +72,17 @@ plan 11;
is (42 if 0), Nil, '"$something if 0" is Nil';
}

{
my $a = 'oops';
{ $a = 'ok' } if 1;
is $a, 'ok', 'Statement-modifier if runs bare block';
}

# RT #78142
{
my $a = 'oops';
{ $a = $^x } if 100;
is $a, 100, 'Statement-modifier if runs block with placeholder';
}

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

use Test;

plan 6;
plan 8;

# test the unless statement modifier

Expand Down Expand Up @@ -38,5 +38,16 @@ plan 6;
is @x, @y, "unless expr on false cond";
}

{
my $a = 'oops';
{ $a = 'ok' } unless 0;
is $a, 'ok', 'Statement-modifier unless runs bare block';
}

{
my $a = 'oops';
{ $a = $^x } unless 0;
is $a, 0, 'Statement-modifier unless runs block with placeholder';
}

# vim: ft=perl6

0 comments on commit 8ab25b4

Please sign in to comment.