-#!perl -T
+#!perl
use strict;
use warnings;
-use lib 't/lib';
-use Variable::Magic::TestThreads;
-
-use Test::More 'no_plan';
-
use Variable::Magic qw<
wizard cast dispell getdata
VMG_OP_INFO_NAME VMG_OP_INFO_OBJECT
>;
+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;
my $op = $_[-1];
my $tid = threads->tid();
+ my $assign_op = ("$]" < 5.037_003) ? 'sassign': 'padsv_store';
+ my $assign_op_cl = ("$]" < 5.037_003) ? 'B::BINOP': 'B::UNOP';
+
if ($op_info == VMG_OP_INFO_OBJECT) {
is_deeply { class => ref($op), name => $op->name },
- { class => 'B::BINOP', name => 'sassign' },
+ { class => $assign_op_cl, name => $assign_op },
"op object in thread $tid is correct";
} else {
- is $op, 'sassign', "op name in thread $tid is correct";
+ is $op, $assign_op, "op name in thread $tid is correct";
}
return 0
}
}
- return;
+ return 1;
}
my $wiz_name = spawn_wiz VMG_OP_INFO_NAME;
$destroyed = 0;
}
+ my $completed = 0;
+
my @threads = map spawn(\&try, $dispell, $wiz), 1 .. 2;
- $_->join for @threads;
+ for my $thr (@threads) {
+ my $res = $thr->join;
+ $completed += $res if defined $res;
+ }
{
lock $c;
- is $c, 2, "get triggered twice";
+ is $c, $completed, "get triggered twice";
}
{
lock $destroyed;
- is $destroyed, (1 - $dispell) * 2, 'destructors';
+ is $destroyed, (1 - $dispell) * $completed, 'destructors';
}
}
}