6 use Test::More tests => 4 + 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;
36 uplevel { is $1, 'x', 'match variables scoping 1' } HERE;
44 uplevel { is $1, 'x', 'match variables scoping 2' } UP;
49 skip 'No state variables before perl 5.10' => 3 * 2 unless "$]" >= 5.010;
51 my $desc = 'state variables';
55 eval 'use feature "state"; sub herp { state $id = 123; return ++$id }';
61 &uplevel(\&herp => UP);
65 for my $run (1 .. 3) {
70 is $@, '', "$desc: run $run did not croak";
71 is $ret, 123 + $run, "$desc: run $run returned the correct value";