]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - t/17-ctl.t
Test the "die in free callback in BEGIN" issue in a new t/17-ctl.t
[perl/modules/Variable-Magic.git] / t / 17-ctl.t
diff --git a/t/17-ctl.t b/t/17-ctl.t
new file mode 100644 (file)
index 0000000..e694a16
--- /dev/null
@@ -0,0 +1,22 @@
+#!perl -T
+
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+
+use Variable::Magic qw/wizard cast getdata/;
+
+# Inspired by B::Hooks::EndOfScope
+# This test is better be left at the beginning of the file, since problems
+# happen at UNITCHECK time
+
+my $wiz;
+
+BEGIN {
+ $wiz = wizard data => sub { $_[1] }, free => sub { $_[1]->(); () };
+ $^H |= 0x020000;
+ cast %^H, $wiz, sub { die "harmless" };
+}
+
+pass 'die in free callback in BEGIN didn\'t segfault';