+use lib 't/lib';
+use VPIT::TestHelpers (
+ threads => [ 'Variable::Magic' => Variable::Magic::VMG_THREADSAFE ],
+);
+
+use Test::Leaner 'no_plan';
+
+my $destroyed : shared = 0;
+my $c : shared = 0;
+
+sub spawn_wiz {
+ my ($op_info) = @_;
+
+ my $desc = "wizard with op_info $op_info in main thread";
+
+ local $@;
+ my $wiz = eval {
+ wizard(
+ data => sub { $_[1] + threads->tid() },
+ get => sub { lock $c; ++$c; 0 },
+ set => sub {
+ my $op = $_[-1];
+ my $tid = threads->tid();
+
+ if ($op_info == VMG_OP_INFO_OBJECT) {
+ is_deeply { class => ref($op), name => $op->name },
+ { class => 'B::BINOP', name => 'sassign' },
+ "op object in thread $tid is correct";
+ } else {
+ is $op, 'sassign', "op name in thread $tid is correct";
+ }
+
+ return 0
+ },
+ free => sub { lock $destroyed; ++$destroyed; 0 },
+ op_info => $op_info,
+ );
+ };
+ is $@, '', "$desc doesn't croak";
+ isnt $wiz, undef, "$desc is defined";
+ is $c, 0, "$desc doesn't trigger magic";
+
+ return $wiz;