if (VMG_THREADSAFE) {
plan tests => 3 + 2 * (2 * 8 + 2) + 2 * (2 * 5 + 2);
- diag 'This will leak a few scalars';
+ my $v = $threads::VERSION;
+ diag "Using threads $v" if defined $v;
+ $v = $threads::shared::VERSION;
+ diag "Using threads::shared $v" if defined $v;
} else {
plan skip_all => 'This Variable::Magic isn\'t thread safe';
}
my $destroyed : shared = 0;
my $c : shared = 0;
-my $wiz = wizard get => sub { ++$c },
- data => sub { $_[1] + threads->tid() },
- free => sub { ++$destroyed };
+my $wiz = eval {
+ wizard get => sub { ++$c },
+ data => sub { $_[1] + threads->tid() },
+ free => sub { ++$destroyed }
+};
is($@, '', "wizard in main thread doesn't croak");
isnt($wiz, undef, "wizard in main thread is defined");
is($c, 0, "wizard in main thread doesn't trigger magic");