]> git.vpit.fr Git - perl/modules/Scope-Upper.git/blob - t/67-uplevel-scope.t
715c50cd4541ceae4ad93238361ba6ccc5447a81
[perl/modules/Scope-Upper.git] / t / 67-uplevel-scope.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 4;
7
8 use Scope::Upper qw<uplevel HERE UP>;
9
10 {
11  our $x = 1;
12  sub {
13   local $x = 2;
14   sub {
15    local $x = 3;
16    uplevel { is $x, 3, 'global variables scoping 1' } HERE;
17   }->();
18  }->();
19 }
20
21 {
22  our $x = 4;
23  sub {
24   local $x = 5;
25   sub {
26    local $x = 6;
27    uplevel { is $x, 6, 'global variables scoping 2' } UP;
28   }->();
29  }->();
30 }
31
32 sub {
33  "abc" =~ /(.)/;
34  sub {
35   "xyz" =~ /(.)/;
36   uplevel { is $1, 'x', 'match variables scoping 1' } HERE;
37  }->();
38 }->();
39
40 sub {
41  "abc" =~ /(.)/;
42  sub {
43   "xyz" =~ /(.)/;
44   uplevel { is $1, 'x', 'match variables scoping 2' } UP;
45  }->();
46 }->();