X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FScope-Upper.git;a=blobdiff_plain;f=t%2F79-uid-threads.t;h=817a144973440f8102f5161a2b7ef93d626ef28f;hp=6f2b06d0b5519aa529aca12c4c652c93a0e910a4;hb=ba6783aa6d08cd998143a4b4cb0d7516597dfc51;hpb=a26097967f907b721862e434af302d0bfb6b3e97 diff --git a/t/79-uid-threads.t b/t/79-uid-threads.t index 6f2b06d..817a144 100644 --- a/t/79-uid-threads.t +++ b/t/79-uid-threads.t @@ -1,10 +1,13 @@ -#!perl -T +#!perl use strict; use warnings; use lib 't/lib'; -use Scope::Upper::TestThreads; +use VPIT::TestHelpers ( + threads => [ 'Scope::Upper' => 'Scope::Upper::SU_THREADSAFE()' ], + 'usleep', +); use Test::Leaner; @@ -24,7 +27,7 @@ sub cb { is uid(UP), $top, "uid(UP) == \$top (in thread $tid)"; - usleep rand(1e6); + usleep rand(2.5e5); ok validate_uid($here), "\$here is valid (in thread $tid)"; ok !validate_uid($up), "\$up is no longer valid (in thread $tid)"; @@ -34,14 +37,16 @@ sub cb { my %uids; my $threads = 0; -for my $thread (map threads->create(\&cb), 1 .. 30) { - ++$threads; +for my $thread (map spawn(\&cb), 1 .. 30) { my $tid = $thread->tid; my $uid = $thread->join; - ++$uids{$uid}; - ok !validate_uid($uid), "\$here is no longer valid (out of thread $tid)"; + if (defined $uid) { + ++$threads; + ++$uids{$uid}; + ok !validate_uid($uid), "\$here is no longer valid (out of thread $tid)"; + } } is scalar(keys %uids), $threads, 'all the UIDs were different'; -done_testing($threads * 5 + 1); +done_testing;