X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FScope-Upper.git;a=blobdiff_plain;f=t%2F59-yield-threads.t;h=26baf502b3b4b4ab1a03d87cea868118e0397ffd;hp=4d6d0b244b2842cc08bc915ff84b93ca0c3345ad;hb=d5bd1454cae95ffddd93e685e3c81b893046fcdb;hpb=1958b3c51f5a5e55822bc1ce12487535a59e12f8 diff --git a/t/59-yield-threads.t b/t/59-yield-threads.t index 4d6d0b2..26baf50 100644 --- a/t/59-yield-threads.t +++ b/t/59-yield-threads.t @@ -1,18 +1,18 @@ -#!perl -T +#!perl use strict; use warnings; -use Scope::Upper qw; - use lib 't/lib'; use VPIT::TestHelpers ( - threads => [ 'Scope::Upper' => Scope::Upper::SU_THREADSAFE ], + threads => [ 'Scope::Upper' => 'Scope::Upper::SU_THREADSAFE()' ], 'usleep', ); use Test::Leaner; +use Scope::Upper qw; + our $z; sub up1 { @@ -20,7 +20,7 @@ sub up1 { local $z = $tid; my $p = "[$tid] up1"; - usleep rand(1e6); + usleep rand(2.5e5); my @res = ( -1, @@ -38,12 +38,17 @@ sub up1 { ); is_deeply \@res, [ -1, $tid .. $tid + 2, -2 ], "$p: yielded correctly"; + + return 1; } my @threads = map spawn(\&up1), 1 .. 30; -$_->join for @threads; +my $completed = 0; +for my $thr (@threads) { + ++$completed if $thr->join; +} pass 'done'; -done_testing(scalar(@threads) + 1); +done_testing($completed + 1);