Unwind-Protect
view release on metacpan or search on metacpan
t/002-die.t view on Meta::CPAN
throws_ok {
unwind_protect { die "ahhh" }
after => sub { push @calls, 'protected' };
} qr{^ahhh at .*002-die.* line 13\b};
is_deeply([splice @calls], ['protected']);
my ($package, $line);
eval {
local $SIG{__DIE__} = sub { ($package, $line) = (caller)[0, 2] };
unwind_protect { die "oh no" }
after => sub { push @calls, 'protected' };
};
is($package, 'main');
is($line, 23);
is_deeply([splice @calls], ['protected']);
( run in 0.624 second using v1.01-cache-2.11-cpan-1e74a51a04c )