X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F41-clone.t;h=a35a2a57303ee8c811d1971dbba66c0be9a97379;hb=33e50e22dc4df6fd53e90e57e4bab26b46a315cb;hp=6214741724b8e72c2d4123891873b9b9686735d4;hpb=9af144fd696d5f97fdf9d43aa561d54f57f8c056;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/41-clone.t b/t/41-clone.t index 6214741..a35a2a5 100644 --- a/t/41-clone.t +++ b/t/41-clone.t @@ -1,18 +1,20 @@ -#!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; @@ -30,12 +32,15 @@ sub spawn_wiz { 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 @@ -100,7 +105,7 @@ sub try { } } - return; + return 1; } my $wiz_name = spawn_wiz VMG_OP_INFO_NAME; @@ -117,16 +122,21 @@ for my $dispell (1, 0) { $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'; } } }