Skip to content

Commit

Permalink
Test if/unless with passing an argument to the block.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmurias committed Oct 26, 2015
1 parent b26314e commit cfcf500
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion t/nqp/88-more-if-tests.t
@@ -1,4 +1,38 @@
plan(1);
plan(7);
my $foo := 0;
1 if $foo++;
ok($foo == 1, "the if condition is evaluated once");

if "value001" -> $value {
ok($value eq "value001", "if statement with an arrow");
} else {
}

if 0 -> $value {
} elsif 0 -> $value {
} elsif "value002" -> $value {
ok($value eq "value002", "elsif statement with an arrow");
}

if nqp::list() {
} else -> $list {
ok(nqp::islist($list), "else with an arrow");
}

unless nqp::list() -> $list {
ok(nqp::islist($list), "unless with an arrow");
}

my $count := 0;

sub side-effect() {
$count := $count + 10;
"value003";
}

if side-effect() -> $value {
ok($value eq "value003", "we get the correct value without reinvoking sideffect");
}

ok($count == 10, "side effect happens once");

0 comments on commit cfcf500

Please sign in to comment.