From e605bd3588d9ad00ca090ec1402292e8301550f2 Mon Sep 17 00:00:00 2001 From: Yuval Kogman Date: Thu, 3 Sep 2009 10:09:10 +0800 Subject: [PATCH] tests for nesting inside catch block --- t/basic.t | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) 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" };