8 # This test checks for $@ being set early during an exceptional
9 # unwinding, and that this early setting does not affect the late
10 # setting used to emit the exception from eval{}. The early setting is
11 # a backward-compatibility hack to satisfy modules that were relying on
12 # the historical early setting in order to detect exceptional unwinding.
13 # This hack should be removed when a proper way to detect exceptional
14 # unwinding has been developed.
19 sub DESTROY { $_[0]->() }
22 return bless(sub { $cleanup->() }, "End");
26 my($uerr, $val, $err);
30 my $c = end { $uerr = $@; $@ = "t2\n"; };
33 is($uerr, "", "\$@ false at start of 'end' block inside 'eval' block");
34 is($val, 1, "successful return from 'eval' block");
35 is($err, "", "\$@ still false after 'end' block inside 'eval' block");
40 my $c = end { $uerr = $@; $@ = "t2\n"; };
43 is($uerr, "t1\n", "true value assigned to \$@ before 'end' block inside 'eval' block");
44 is($val, 1, "successful return from 'eval' block");
45 is($err, "", "\$@ still false after 'end' block inside 'eval' block");
49 my $c = end { $uerr = $@; $@ = "t2\n"; };
56 is($val, undef, "undefined return value from 'eval' block with 'die'");
62 my $c = end { $uerr = $@; $@ = "t2\n"; };
69 is($val, undef, "undefined return value from 'eval' block with 'die'");