X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F10-join.t;h=ba86a97b31dd43d43012402f295de83ef4945163;hb=40b4729cfac7e9a063232fac1c7601fb0885e82c;hp=b3f92c2a6c552469ae0d8b8021408f1b3e5b4aca;hpb=15b9171b2fc61b12e0dcc123369fc2b66fe87012;p=perl%2Fmodules%2FThread-Cleanup.git diff --git a/t/10-join.t b/t/10-join.t index b3f92c2..ba86a97 100644 --- a/t/10-join.t +++ b/t/10-join.t @@ -3,20 +3,10 @@ use strict; use warnings; -use Config qw/%Config/; +use lib 't/lib'; +use Thread::Cleanup::TestThreads; -BEGIN { - if (!$Config{useithreads}) { - require Test::More; - Test::More->import; - plan(skip_all => 'This perl wasn\'t built to support threads'); - } -} - -use threads; -use threads::shared; - -use Test::More tests => 5 * (2 + 2) + 1; +use Test::More 'no_plan'; use Thread::Cleanup; @@ -61,19 +51,15 @@ sub cb { local $x = -$tid; } -my @tids; -my @t = map { +my @threads = map { local $x = $_; - my $thr = threads->create(\&cb, $_); - push @tids, $thr->tid; - $thr; + spawn(\&cb, $_); } 0 .. 4; -diag "Using threads $threads::VERSION"; -diag "Using threads::shared $threads::shared::VERSION"; +my @tids = map $_->tid, @threads; -$_->join for @t; +$_->join for @threads; is $x, -1, '$x in the main thread';