6 use Test::More tests => 4 * 3 + 3;
14 my $up = Scope::Context->up;
15 $up->reap(sub { $flag = -1 });
16 is $flag, undef, 'reap: not yet 1';
19 is $flag, 1, 'reap: not yet 2';
22 is $flag, -1, 'reap: done';
31 my $up = Scope::Context->up(2);
32 $up->localize('$x', -1);
33 is $x, 2, 'localize: not yet 1';
36 is $x, 1, 'localize: not yet 2';
39 is $x, -1, 'localize: done';
48 my $up = Scope::Context->up(2);
49 $up->localize_elem('%h', 'x', -1);
50 is $h{x}, 2, 'localize_elem: not yet 1';
53 is $h{x}, 1, 'localize_elem: not yet 2';
56 is $h{x}, -1, 'localize_elem: done';
65 my $up = Scope::Context->up(2);
66 $up->localize_delete('%h', 'x');
67 is $h{x}, 2, 'localize_delete: not yet 1';
70 is $h{x}, 1, 'localize_delete: not yet 2';
73 ok !exists($h{x}), 'localize_delete: done';
79 my $up = Scope::Context->sub(1);
81 fail 'unwind: not reached 1';
83 fail 'unwind: not reached 2';
86 is_deeply \@res, [ 1, 2, 3 ], 'unwind: done';
92 my $up = Scope::Context->up;
94 fail 'yield: not reached 1';
96 fail 'yield: not reached 2';
99 is_deeply \@res, [ 4, 5, 6 ], 'yield: done';
107 my $up = Scope::Context->sub(1);
108 my $name = $up->uplevel(
109 sub { (caller 0)[$_[0]] } => 3
111 is $name, 'main::outer', 'uplevel: done';