From: Yuval Kogman Date: Thu, 3 Sep 2009 02:09:10 +0000 (+0800) Subject: tests for nesting inside catch block X-Git-Tag: Try-Tiny-0.03~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e605bd3588d9ad00ca090ec1402292e8301550f2;p=p5sagit%2FTry-Tiny.git tests for nesting inside catch block --- diff --git a/t/basic.t b/t/basic.t index 400b1fb..ebc4106 100644 --- a/t/basic.t +++ b/t/basic.t @@ -3,7 +3,7 @@ use strict; #use warnings; -use Test::More tests => 15; +use Test::More tests => 19; BEGIN { use_ok 'Try::Tiny' }; @@ -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" };