Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Swap $result variables for try-die-CATCH
  • Loading branch information
vendethiel committed Apr 5, 2014
1 parent 2274ac4 commit d90866d
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions S03-operators/orelse.t
Expand Up @@ -12,31 +12,39 @@ ok (1 orelse ($tracker = 1)), 'sanity';
nok $tracker, 'orelse thunks';

#?rakudo todo "orelse exception semantics"
lives_ok {
my $result = 0;
die "oh noes!" orelse $result = 1;
ok $result, "orelse continues after an exception";
{
try {
die "oh noes!" orelse pass("orelse continues after an exception");
CATCH { flunk "orelse shouldn't rethrow exceptions" }
}
}

#?rakudo todo "orelse exception semantics"
lives_ok {
my $result = 0;
die "oh noes!" orelse $result = ~$! eq "oh noes!";
ok $result, "orelse sets $! after an exception";
{
try {
die "oh noes!" orelse ok(~$! eq "oh noes!", "orelse sets $! after an exception");
CATCH { flunk "orelse shouldn't rethrow exceptions" }
}
}

#?rakudo todo "orelse exception semantics"
lives_ok {
my $result = 0;
die "oh noes!" orelse -> $foo { $result = ~$foo eq "oh noes!" };
ok $result, "orelse passes $! to one argument after an exception";
{
try {
die "oh noes!" orelse -> $foo {
ok ~$foo eq "oh noes!", "orelse passes $! to one argument after an exception";
};
CATCH { flunk "orelse shouldn't rethrow exceptions" }
}
}

#?rakudo todo "orelse exception semantics"
lives_ok {
my $result = 0;
die "oh noes!" orelse -> $foo, $bar { $result = ~$foo eq "oh noes!" && ~$bar eq "oh noes!" };
ok $result, "orelse passes $! to two arguments after an exception";
{
try {
die "oh noes!" orelse -> $foo, $bar {
ok ~$foo eq "oh noes!" && ~$bar eq "oh noes!", "orelse passes $! to two arguments after an exception";
};
CATCH { flunk "orelse shouldn't rethrow exceptions" }
}
}


Expand Down

0 comments on commit d90866d

Please sign in to comment.