X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F40-threads.t;h=85d51934635b395a1801f4378fe6d2b54f8eaa68;hb=33e50e22dc4df6fd53e90e57e4bab26b46a315cb;hp=9b2d2fa2c95fd59bfbf691ab9413cea011703006;hpb=166e85102e0d03c7ab5e21cba28e131c2d87de54;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/40-threads.t b/t/40-threads.t index 9b2d2fa..85d5193 100644 --- a/t/40-threads.t +++ b/t/40-threads.t @@ -33,12 +33,15 @@ sub try { set => sub { my $op = $_[-1]; + my $assign_op = ("$]" < 5.037_003) ? 'sassign': 'padsv_store'; + my $assign_op_cl = ("$]" < 5.037_003) ? 'B::BINOP': 'B::UNOP'; + if ($op_info eq '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; @@ -102,7 +105,8 @@ sub try { is $c, 1, "get in thread $tid after dispell doesn't trigger magic"; } } - return; # Ugly if not here + + return 1; } for my $dispell (1, 0) { @@ -111,11 +115,16 @@ for my $dispell (1, 0) { $destroyed = 0; } + my $completed = 0; + my @threads = map spawn(\&try, $dispell, $_), ('name') x 2, ('object') x 2; - $_->join for @threads; + for my $thr (@threads) { + my $res = $thr->join; + $completed += $res if defined $res; + } { lock $destroyed; - is $destroyed, (1 - $dispell) * 4, 'destructors'; + is $destroyed, (1 - $dispell) * $completed, 'destructors'; } }