X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F10-join.t;h=ba86a97b31dd43d43012402f295de83ef4945163;hb=981090d572d766fbcccf048b3777e6fd1edc4fea;hp=0a4ea4de61b8c4bda0267b87382825f38e75727c;hpb=ba8793aed63c1cd66942055b1c2d934bd1c28a9d;p=perl%2Fmodules%2FThread-Cleanup.git diff --git a/t/10-join.t b/t/10-join.t index 0a4ea4d..ba86a97 100644 --- a/t/10-join.t +++ b/t/10-join.t @@ -3,25 +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; - -BEGIN { - defined and diag "Using threads $_" for $threads::VERSION; - defined and diag "Using threads::shared $_" for $threads::shared::VERSION; -} +use Test::More 'no_plan'; use Thread::Cleanup; @@ -66,16 +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; -$_->join for @t; +my @tids = map $_->tid, @threads; + +$_->join for @threads; is $x, -1, '$x in the main thread';