6 use Test::More tests => 4 + 8 + 8 + 18 + 4 + 8 + 6 + 11 + 5 + 17;
8 use Scope::Upper qw/reap/;
12 sub add { local $_; my $y = $_[1]; reap sub { $x += $y }, $_[0] + 1 }
19 is($x, 0, '1 didn\'t run');
29 is($_, 3, '$_ has the right value');
32 is($_, 3, '$_ has the right value');
34 is($_, 7, '$_ has the right value');
35 is($x, 0, '1 didn\'t run');
38 is($_, 3, '$_ has the right value');
47 is($x, 0, '1 didn\'t run');
50 is($x, 0, '1 and 2 didn\'t run');
52 is($x, 2, '1 didn\'t run, 2 ran');
55 is($x, 2, '1 and 3 didn\'t run, 2 ran');
57 is($x, 6, '1 didn\'t run, 2 and 3 ran');
59 is($x, 7, '1, 2 and 3 ran');
67 is($_, 3, '$_ has the right value');
70 is($_, 3, '$_ has the right value');
72 is($x, 0, '1 didn\'t run');
73 is($_, 5, '$_ has the right value');
76 is($_, 5, '$_ has the right value');
78 is($_, 7, '$_ has the right value');
79 is($x, 0, '1 and 2 didn\'t run');
81 is($x, 2, '1 didn\'t run, 2 ran');
82 is($_, 5, '$_ has the right value');
85 is($_, 9, '$_ has the right value');
88 is($_, 11, '$_ has the right value');
89 is($x, 2, '1 and 3 didn\'t run, 2 ran');
91 is($x, 6, '1 didn\'t run, 2 and 3 ran');
92 is($_, 5, '$_ has the right value');
94 is($x, 7, '1, 2 and 3 ran');
95 is($_, 3, '$_ has the right value');
105 is($x, 0, '1 and 2 didn\'t run');
107 is($x, 3, '1 and 2 ran');
118 is($_, 5, '$_ has the right value');
121 is($_, 7, '$_ has the right value');
122 is($x, 0, '1 and 2 didn\'t run');
124 is($_, 9, '$_ has the right value');
126 is($x, 3, '1 and 2 ran');
127 is($_, 3, '$_ has the right value');
138 is($x, 0, '1 didn\'t run');
140 is($x, 0, '1 didn\'t run');
142 is($x, 0, '1 didn\'t run');
154 is($x, 0, '1 didn\'t run');
156 is($x, 0, '1 didn\'t run');
163 is($x, 1, '2 didn\'t run');
165 is($x, 1, '2 didn\'t run');
168 is($x, 1, '2 and 3 didn\'t run');
170 is($x, 1, '2 and 3 didn\'t run');
172 is($x, 5, '2 didn\'t run, 3 ran');
174 is($x, 7, '2 and 3 ran');
178 sub bleh { add(1, 2); }
185 is($x, 0, '1 didn\'t run');
187 is($x, 0, '1 didn\'t run');
194 is($_, 7, '$_ has the right value');
197 is($_, 9, '$_ has the right value');
199 is($_, 9, '$_ has the right value');
205 is($_, 7, '$_ has the right value');
206 is($x, 0, '1, 2 didn\'t run');
208 is($x, 0, '1, 2, 3, 4 didn\'t run');
209 is($_, 7, '$_ has the right value');
211 is($_, 7, '$_ has the right value');
219 is($_, 3, '$_ has the right value');
222 is($_, 5, '$_ has the right value');
223 is($x, 0, '1 didn\'t run');
226 is($x, 2, '1, 3, 4 and 5 didn\'t run, 2 ran');
227 is($_, 5, '$_ has the right value');
229 is($x, 22, '1 and 4 didn\'t run, 2, 3 and 5 ran');
231 is($x, 30, '1 didn\'t run, 2, 3, 4 and 5 ran');