]> git.vpit.fr Git - perl/modules/Scope-Upper.git/blob - t/25-localize-multi.t
fix unwind()
[perl/modules/Scope-Upper.git] / t / 25-localize-multi.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 10 + 5 + 6;
7
8 use Scope::Upper qw<localize UP HERE>;
9
10 our $x;
11
12 sub loc { local $x; my $y = $_[0]; localize '$x', $y => $_[1] }
13
14 $x = 0;
15 {
16  is($x, 0, 'start');
17  local $x = 7;
18  {
19   local $x = 8;
20   loc 1 => UP;
21   is($x, 8, 'not localized');
22   local $x = 9;
23   is($x, 9, 'not localized');
24  }
25  is($x, 1, 'localized to 1');
26  {
27   is($x, 1, 'localized to 1');
28   {
29    is($x, 1, 'localized to 1');
30    local $x = 10;
31    is($x, 10, 'localized to undef');
32   }
33   is($x, 1, 'localized to 1');
34  }
35  is($x, 1, 'localized to 1');
36 }
37 is($x, 0, 'end');
38
39 $x = 0;
40 {
41  is($x, 0, 'start');
42  local $x = 8;
43  {
44   {
45    local $x = 8;
46    loc 1 => UP UP;
47    is($x, 8, 'not localized');
48   }
49   loc 2 => HERE;
50   is($x, 2, 'localized to 2');
51  }
52  is($x, 1, 'localized to 1');
53 }
54 is($x, 0, 'end');
55
56 $x = 0;
57 {
58  is($x, 0, 'start');
59  local $x;
60  {
61   {
62    loc 1 => UP UP;
63    is($x, undef, 'not localized');
64    local $x;
65    loc 2 => UP;
66    is($x, undef, 'not localized');
67   }
68   is($x, 2, 'localized to 2');
69  }
70  is($x, 1, 'localized to 1');
71 }
72 is($x, 0, 'end');
73