+{
+ my $wiz = wizard free => sub { die 'avocado' };
+ my $check = sub { like $@, expect('avocado', $0), $_[0] };
+
+ for my $local_out (0, 1) {
+ for my $local_in (0, 1) {
+ my $desc = "die in free callback";
+ if ($local_in or $local_out) {
+ $desc .= ' with $@ localized ';
+ if ($local_in and $local_out) {
+ $desc .= 'inside and outside';
+ } elsif ($local_in) {
+ $desc .= 'inside';
+ } else {
+ $desc .= 'outside';
+ }
+ }
+
+ local $@ = $local_out ? 'xxx' : undef;
+ eval {
+ local $@ = 'yyy' if $local_in;
+ my $x;
+ cast $x, $wiz;
+ };
+ $check->("$desc at eval BLOCK 1a");
+
+ local $@ = $local_out ? 'xxx' : undef;
+ eval q{
+ local $@ = 'yyy' if $local_in;
+ my $x;
+ cast $x, $wiz;
+ };
+ $check->("$desc at eval STRING 1a");
+
+ local $@ = $local_out ? 'xxx' : undef;
+ eval {
+ my $x;
+ local $@ = 'yyy' if $local_in;
+ cast $x, $wiz;
+ };
+ $check->("$desc at eval BLOCK 1b");
+
+ local $@ = $local_out ? 'xxx' : undef;
+ eval q{
+ my $x;
+ local $@ = 'yyy' if $local_in;
+ cast $x, $wiz;
+ };
+ $check->("$desc at eval STRING 1b");
+
+ local $@ = $local_out ? 'xxx' : undef;
+ eval {
+ local $@ = 'yyy' if $local_in;
+ my $x;
+ my $y = \$x;
+ &cast($y, $wiz);
+ };
+ $check->("$desc at eval BLOCK 2a");
+
+ local $@ = $local_out ? 'xxx' : undef;
+ eval q{
+ local $@ = 'yyy' if $local_in;
+ my $x;
+ my $y = \$x;
+ &cast($y, $wiz);
+ };
+ $check->("$desc at eval STRING 2a");
+
+ local $@ = $local_out ? 'xxx' : undef;
+ eval {
+ my $x;
+ my $y = \$x;
+ local $@ = 'yyy' if $local_in;
+ &cast($y, $wiz);
+ };
+ $check->("$desc at eval BLOCK 2b");
+
+ local $@ = $local_out ? 'xxx' : undef;
+ eval q{
+ my $x;
+ my $y = \$x;
+ local $@ = 'yyy' if $local_in;
+ &cast($y, $wiz);
+ };
+ $check->("$desc at eval STRING 2b");
+
+ local $@ = $local_out ? 'xxx' : undef;
+ eval {
+ local $@ = 'yyy' if $local_in;
+ my $x;
+ cast $x, $wiz;
+ my $y = 1;
+ };
+ $check->("$desc at eval BLOCK 3");
+
+ local $@ = $local_out ? 'xxx' : undef;
+ eval q{
+ local $@ = 'yyy' if $local_in;
+ my $x;
+ cast $x, $wiz;
+ my $y = 1;
+ };
+ $check->("$desc at eval STRING 3");
+
+ local $@ = $local_out ? 'xxx' : undef;
+ eval {
+ local $@ = 'yyy' if $local_in;
+ {
+ my $x;
+ cast $x, $wiz;
+ }
+ };
+ $check->("$desc at block in eval BLOCK");
+
+ local $@ = $local_out ? 'xxx' : undef;
+ eval q{
+ local $@ = 'yyy' if $local_in;
+ {
+ my $x;
+ cast $x, $wiz;
+ }
+ };
+ $check->("$desc at block in eval STRING");
+
+ ok defined($desc), "$desc did not over-unwind the save stack";
+ }
+ }
+}
+