X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F55-unwind-multi.t;h=07df3ebdc153cd55329e0b8cf793d9abe74976d2;hb=2ede1b8c4c9b948ddfe278e44f19f4a57648cf10;hp=59c869c45514740a0caf11fc0065a5b8ea9cc33b;hpb=daa5478303f254eff6015045396920baafee0688;p=perl%2Fmodules%2FScope-Upper.git diff --git a/t/55-unwind-multi.t b/t/55-unwind-multi.t index 59c869c..07df3eb 100644 --- a/t/55-unwind-multi.t +++ b/t/55-unwind-multi.t @@ -3,9 +3,9 @@ use strict; use warnings; -use Test::More tests => 13; +use Test::More tests => 13 + 3; -use Scope::Upper qw; +use Scope::Upper qw; my ($l1, $l2); @@ -63,3 +63,42 @@ $l1 = 5; $l2 = 999; is_deeply [ a() ], [ qw, 'in a' ], 'l1=5, l2=?'; + +# Unwinding while unwinding +{ + package Scope::Upper::TestGuard; + + sub new { + my $class = shift; + bless { cb => $_[0] }, $class; + } + + sub DESTROY { + $_[0]->{cb}->() + } +} + +{ + my $desc = 'unwinding while unwinding'; + local $@; + + eval { + my @res = sub { + sub { + my $guard = Scope::Upper::TestGuard->new(sub { + my @res = sub { + sub { + unwind @_ => CALLER(1); + }->(@_); + fail "$desc (second): not reached"; + }->(qw); + is_deeply \@res, [ qw ], "$desc (second): correct returned values"; + }); + unwind @_ => CALLER(1); + }->(@_); + fail "$desc (first): not reached"; + }->(qw); + is_deeply \@res, [ qw ], "$desc (first): correct returned values"; + }; + is $@, '', "$desc: did not croak"; +}