Skip to content

Commit

Permalink
Test sunk for sinks last statement sub calls
Browse files Browse the repository at this point in the history
  • Loading branch information
zoffixznet committed Feb 26, 2018
1 parent be73087 commit 01b59fb
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion S04-statements/sink.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 7;
plan 8;

# RT #117235
{
Expand Down Expand Up @@ -77,3 +77,19 @@ plan 7;

is $sunk, False, "we don't sink the result of thing() .= method-name";
}

# https://github.com/rakudo/rakudo/issues/1531
subtest 'sub calls in last statement of sunk `for` get sunk' => {
plan 4;
my $a; $a Z+= 2 for ^3;
is-deeply $a, 6, 'postfix `for`, Z+= op';

my $b; for ^3 { $b Z+= 2 }
is-deeply $b, 6, 'block `for`, Z+= op';

throws-like { sub foo {fail}; foo for ^1; Nil }, Exception,
'postfix `for` with sub that returns Failure';

throws-like { sub foo {fail}; for ^1 { foo }; Nil }, Exception,
'block `for` with sub that returns Failure';
}

0 comments on commit 01b59fb

Please sign in to comment.