7 use Scope::Upper::TestThreads;
11 use Scope::Upper qw<uplevel UP>;
16 my @c = caller($depth);
23 is depth(), 0, 'check top depth';
24 is sub { depth() }->(), 1, 'check subroutine call depth';
25 is do { local $@; eval { depth() } }, 1, 'check eval block depth';
30 my $d = splice @_, 1, 1;
33 is depth(), $d - 1, "$p: correct depth inside";
38 my $tid = threads->tid();
51 my @ret = &uplevel(\&cb => ($p, $d, $tid + 1, $tid) => UP);
52 is depth(), $d, "$p: correct depth after uplevel";
61 is_deeply \@res, [ -2, -1, $tid .. $tid + 2, 1, 2 ], "$p: returns correctly";
64 my @threads = map spawn(\&up1), 1 .. 30;
66 $_->join for @threads;
68 done_testing(3 + scalar(@threads) * 3);