Skip to content

Commit

Permalink
tests for nesting inside catch block
Browse files Browse the repository at this point in the history
  • Loading branch information
nothingmuch committed Sep 3, 2009
1 parent c491888 commit e605bd3
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion t/basic.t
Expand Up @@ -3,7 +3,7 @@
use strict;
#use warnings;

use Test::More tests => 15;
use Test::More tests => 19;

BEGIN { use_ok 'Try::Tiny' };

Expand Down Expand Up @@ -74,6 +74,34 @@ is( scalar(try { "foo", "bar", "gorch" }), "gorch", "scalar context" );
is_deeply( [ try {qw(foo bar gorch)} ], [qw(foo bar gorch)], "list context" );


lives_ok {
try {
die "foo";
} catch {
my $err = shift;

try {
like $err, qr/foo/;
} catch {
fail("shouldn't happen");
};

pass "got here";
}
} "try in try catch block";

throws_ok {
try {
die "foo";
} catch {
my $err = shift;

try { } catch { };

die "rethrowing $err";
}
} qr/rethrowing foo/, "rethrow with try in catch block";


sub Evil::DESTROY {
eval { "oh noes" };
Expand Down

0 comments on commit e605bd3

Please sign in to comment.