]> git.vpit.fr Git - perl/modules/Thread-Cleanup.git/blobdiff - t/10-join.t
Skip threads tests unless perl version is 5.13.4 or greater
[perl/modules/Thread-Cleanup.git] / t / 10-join.t
index b957f25138986e93d806e60cfad3c3d87d258a20..ba86a97b31dd43d43012402f295de83ef4945163 100644 (file)
@@ -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';