7 use VPIT::TestHelpers (
8 threads => [ 'Scope::Upper' => 'Scope::Upper::SU_THREADSAFE()' ],
14 use Scope::Upper qw<uplevel UP>;
19 my @c = caller($depth);
26 is depth(), 0, 'check top depth';
27 is sub { depth() }->(), 1, 'check subroutine call depth';
28 is do { local $@; eval { depth() } }, 1, 'check eval block depth';
33 my $d = splice @_, 1, 1;
36 is depth(), $d - 1, "$p: correct depth inside";
41 my $tid = threads->tid();
54 my @ret = &uplevel(\&cb => ($p, $d, $tid + 1, $tid) => UP);
55 is depth(), $d, "$p: correct depth after uplevel";
64 is_deeply \@res, [ -2, -1, $tid .. $tid + 2, 1, 2 ], "$p: returns correctly";
67 my @threads = map spawn(\&up1), 1 .. 30;
69 $_->join for @threads;