Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
explicitly test return value of try { }
  • Loading branch information
moritz committed Jan 12, 2013
1 parent 76c7334 commit cbe1ad7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion S04-statements/try.t
Expand Up @@ -4,7 +4,7 @@ use Test;

# L<S04/"Statement parsing"/"or try {...}">

plan 24;
plan 26;

#?pugs todo
{
Expand All @@ -14,6 +14,12 @@ plan 24;
ok($! ~~ /foo/, "error var was set");
};

# try should return Nil if an exception was caught
{
ok (try { die 'foo' }) === Nil, 'try returns Nil when exception was caught';
ok (try { die 'foo'; CATCH { default { } } }) === Nil, '... even when there was a CATCH block';
}

# try should work when returning an array or hash
{
my @array = try { 42 };
Expand Down

0 comments on commit cbe1ad7

Please sign in to comment.