6 use Test::More tests => 2 + 2 * 6 + 3 * 2;
8 use Scope::Upper qw<uplevel HERE UP>;
16 uplevel { is $x, 3, 'global variables scoping 1' } HERE;
27 uplevel { is $x, 6, 'global variables scoping 2' } UP;
34 is $1, 'a', 'match variables scoping 1: before 1';
37 is $1, 'u', 'match variables scoping 1: before 2';
39 is $1, 'u', 'match variables scoping 1: before 3';
41 is $1, 'x', 'match variables scoping 1: after 1';
43 is $1, 'u', 'match variables scoping 1: after 2';
45 is $1, 'a', 'match variables scoping 1: after 3';
50 is $1, 'a', 'match variables scoping 2: before 1';
53 is $1, 'u', 'match variables scoping 2: before 2';
55 is $1, 'u', 'match variables scoping 2: before 3';
57 is $1, 'x', 'match variables scoping 2: after 1';
59 is $1, 'u', 'match variables scoping 2: after 2';
61 is $1, 'a', 'match variables scoping 2: after 3';
65 skip 'No state variables before perl 5.10' => 3 * 2 unless "$]" >= 5.010;
67 my $desc = 'state variables';
71 eval 'use feature "state"; sub herp { state $id = 123; return ++$id }';
77 &uplevel(\&herp => UP);
81 for my $run (1 .. 3) {
86 is $@, '', "$desc: run $run did not croak";
87 is $ret, 123 + $run, "$desc: run $run returned the correct value";