t/92-pod-coverage.t
t/95-portability-files.t
t/99-kwalitee.t
+t/lib/Variable/Magic/TestDestroyRequired.pm
t/lib/Variable/Magic/TestDieRequired.pm
t/lib/Variable/Magic/TestValue.pm
t/lib/Variable/Magic/TestWatcher.pm
if (hv_delete(MY_CXT.wizards, buf, sprintf(buf, "%u", w->sig), 0) != wiz)
return 0;
}
- SvFLAGS(wiz) |= SVf_BREAK;
- FREETMPS;
+
+ /* Unmortalize the wizard to avoid it being freed in weird places. */
+ if (SvTEMP(wiz) && !SvREFCNT(wiz)) {
+ const I32 myfloor = PL_tmps_floor;
+ I32 i;
+ for (i = PL_tmps_ix; i > myfloor; --i) {
+ SV * const sv = PL_tmps_stack[i];
+ if (sv && sv == wiz)
+ PL_tmps_stack[i] = NULL;
+ }
+ }
if (w->cb_data) SvREFCNT_dec(SvRV(w->cb_data));
if (w->cb_get) SvREFCNT_dec(SvRV(w->cb_get));
use strict;
use warnings;
-use Test::More tests => 16;
+use Test::More tests => 17;
use Variable::Magic qw/wizard cast dispell getdata getsig/;
ok($res, 're-re-cast on self is valid');
}
+eval q[
+ use lib 't/lib';
+ BEGIN { require Variable::Magic::TestDestroyRequired; }
+];
+is $@, '', 'wizard destruction at the end of BEGIN-time require doesn\'t panic';
+
if ((defined $ENV{PERL_DESTRUCT_LEVEL} and $ENV{PERL_DESTRUCT_LEVEL} >= 3)
or eval "use Perl::Destruct::Level level => 3; 1") {
diag 'Test global destruction';
}
-
-# is($c, 0, 'magic destructor is called');
--- /dev/null
+package Variable::Magic::TestDestroyRequired;
+
+use Variable::Magic;
+
+my $tag = Variable::Magic::wizard();
+
+1;