9 Test::More::plan(skip_all => $msg);
12 use Config qw<%Config>;
15 my $force = $ENV{PERL_SCOPE_UPPER_TEST_THREADS} ? 1 : !1;
16 my $t_v = $force ? '0' : '1.67';
17 skipall 'This perl wasn\'t built to support threads'
18 unless $Config{useithreads};
19 skipall 'perl 5.13.4 required to test thread safety'
20 unless $force or "$]" >= 5.013004;
21 skipall "threads $t_v required to test thread safety"
22 unless eval "use threads $t_v; 1";
27 use Scope::Upper qw<unwind UP SU_THREADSAFE>;
32 skipall 'This Scope::Upper isn\'t thread safe' unless SU_THREADSAFE;
33 plan tests => ($num = 30);
34 defined and diag "Using threads $_" for $threads::VERSION;
35 if (eval "use Time::HiRes; 1") {
36 defined and diag "Using Time::HiRes $_" for $Time::HiRes::VERSION;
37 *usleep = \&Time::HiRes::usleep;
39 diag 'Using fallback usleep';
41 my $s = int($_[0] / 2.5e5);
50 my $tid = threads->tid();
62 my $foo = unwind $tid .. $tid + 2 => UP;
63 fail "$p: not reached";
66 fail "$p: not reached";
71 is_deeply \@res, [ -1, $tid .. $tid + 2, -2 ], "$p: unwinded correctly";
74 $_->join for map threads->create(\&up1), 1 .. $num;