6 use Test::More tests => 3 + 7 * 2 + 8;
8 use Scope::Upper qw<uplevel HERE UP>;
13 my @c = caller($depth);
20 is depth(), 0, 'check top depth';
21 is sub { depth() }->(), 1, 'check subroutine call depth';
22 is do { local $@; eval { depth() } }, 1, 'check eval block depth';
25 my $desc = 'uplevel in uplevel : lower frame';
29 is depth(), 2, "$desc: correct depth 1";
31 is depth(), 2, "$desc: correct depth 2";
33 is depth(), 3, "$desc: correct depth 3";
35 is depth(), 3, "$desc: correct depth 4";
42 is $@, '', "$desc: no error";
43 is depth(), 0, "$desc: correct depth outside";
44 is_deeply \@ret, [ 1 .. 9 ], "$desc: correct return value"
48 my $desc = 'uplevel in uplevel : same frame';
52 is depth(), 2, "$desc: correct depth 1";
54 is depth(), 2, "$desc: correct depth 2";
56 is depth(), 3, "$desc: correct depth 3";
58 is depth(), 2, "$desc: correct depth 4";
65 is $@, '', "$desc: no error";
66 is depth(), 0, "$desc: correct depth outside";
67 is_deeply \@ret, [ 11 .. 19 ], "$desc: correct return value"
71 my $desc = 'uplevel in uplevel : higher frame';
75 is depth(), 2, "$desc: correct depth 1";
77 is depth(), 3, "$desc: correct depth 2";
79 is depth(), 3, "$desc: correct depth 3";
81 is depth(), 4, "$desc: correct depth 4";
83 is depth(), 2, "$desc: correct depth 5";
91 is $@, '', "$desc: no error";
92 is depth(), 0, "$desc: correct depth outside";
93 is_deeply \@ret, [ 20 .. 29, '2A' ], "$desc: correct return value"