X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F67-uplevel-scope.t;h=92105fcfec759dbeba8a612d9ec5c1547e82c5ed;hb=c85df5478ff2d9380ee42b0e5a70461d063745d6;hp=715c50cd4541ceae4ad93238361ba6ccc5447a81;hpb=361c0283804eb19b323c57003e40ff18ac84c089;p=perl%2Fmodules%2FScope-Upper.git diff --git a/t/67-uplevel-scope.t b/t/67-uplevel-scope.t index 715c50c..92105fc 100644 --- a/t/67-uplevel-scope.t +++ b/t/67-uplevel-scope.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 4; +use Test::More tests => 4 + 3 * 2; use Scope::Upper qw; @@ -44,3 +44,30 @@ sub { uplevel { is $1, 'x', 'match variables scoping 2' } UP; }->(); }->(); + +SKIP: { + skip 'No state variables before perl 5.10' => 3 * 2 unless "$]" >= 5.010; + + my $desc = 'state variables'; + + { + local $@; + eval 'use feature "state"; sub herp { state $id = 123; return ++$id }'; + die $@ if $@; + } + + sub derp { + sub { + &uplevel(\&herp => UP); + }->(); + } + + for my $run (1 .. 3) { + local $@; + my $ret = eval { + derp() + }; + is $@, '', "$desc: run $run did not croak"; + is $ret, 123 + $run, "$desc: run $run returned the correct value"; + } +}