From: Vincent Pit Date: Fri, 9 Jan 2009 19:02:53 +0000 (+0100) Subject: Test dieing into a reap callback X-Git-Tag: v0.04~17 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=36412f421047ac8b6b71445705ff07ebdfeb4c78;p=perl%2Fmodules%2FScope-Upper.git Test dieing into a reap callback --- diff --git a/t/13-reap-ctl.t b/t/13-reap-ctl.t index f9ca9cd..5dd5ea9 100644 --- a/t/13-reap-ctl.t +++ b/t/13-reap-ctl.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 28; +use Test::More tests => 38; use Scope::Upper qw/reap/; @@ -121,3 +121,39 @@ $y = undef; is $x, 1, 'die - reap inside eval [ok - x]'; is $y, 1, 'die - reap inside eval [ok - y]'; } + +$y = undef; +{ + local $x = 1; + eval { + local $x = 2; + eval { + local $x = 3; + reap { ++$y; die "reaped\n" } => 0; + is $x, 3, 'die in reap at eval [not yet - x]'; + is $y, undef, 'die in reap at eval [not yet - y]'; + }; # should trigger here, but the die isn't catched by this eval + die "failed\n"; + }; + is $@, "reaped\n", 'die in reap at eval [ok - $@]'; + is $x, 1, 'die in reap at eval [ok - x]'; + is $y, 1, 'die in reap at Eval [ok - y]'; +} + +$y = undef; +{ + local $x = 1; + eval { + local $x = 2; + { + local $x = 3; + reap { ++$y; die "reaped\n" } => 0; + is $x, 3, 'die in reap inside eval [not yet - x]'; + is $y, undef, 'die in reap inside eval [not yet - y]'; + } # should trigger here + die "failed\n"; + }; + is $@, "reaped\n", 'die in reap inside eval [ok - $@]'; + is $x, 1, 'die in reap inside eval [ok - x]'; + is $y, 1, 'die in reap inside eval [ok - y]'; +}