]> git.vpit.fr Git - perl/modules/Scope-Upper.git/blob - t/54-unwind-threads.t
Make some room in test ordering
[perl/modules/Scope-Upper.git] / t / 54-unwind-threads.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use lib 't/lib';
7 use Scope::Upper::TestThreads;
8
9 use Test::Leaner;
10
11 use Scope::Upper qw<unwind UP>;
12
13 our $z;
14
15 sub up1 {
16  my $tid  = threads->tid();
17  local $z = $tid;
18  my $p    = "[$tid] up1";
19
20  usleep rand(1e6);
21
22  my @res = (
23   -1,
24   sub {
25    my @dummy = (
26     999,
27     sub {
28      my $foo = unwind $tid .. $tid + 2 => UP;
29      fail "$p: not reached";
30     }->()
31    );
32    fail "$p: not reached";
33   }->(),
34   -2
35  );
36
37  is_deeply \@res, [ -1, $tid .. $tid + 2, -2 ], "$p: unwinded correctly";
38 }
39
40 my @threads = map spawn(\&up1), 1 .. 30;
41
42 $_->join for @threads;
43
44 pass 'done';
45
46 done_testing(scalar(@threads) + 1);