]> git.vpit.fr Git - perl/modules/Variable-Temp.git/blob - t/10-base.t
Rename the global variable in t/10-base.t
[perl/modules/Variable-Temp.git] / t / 10-base.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use Variable::Temp 'set_temp';
7
8 use Test::More tests => 7 + 13;
9
10 my $x = 1;
11 is $x, 1;
12 {
13  set_temp $x => 2;
14  is $x, 2;
15  $x = 3;
16  is $x, 3;
17  {
18   set_temp $x => 4;
19   is $x, 4;
20   set_temp $x => 5;
21   is $x, 5;
22  }
23  is $x, 3;
24 }
25 is $x, 1;
26
27 our $X = 1;
28 is $X, 1;
29 {
30  set_temp $X => 2;
31  is $X, 2;
32  $X = 3;
33  is $X, 3;
34  {
35   set_temp $X => 4;
36   is $X, 4;
37   set_temp $X => 5;
38   is $X, 5;
39  }
40  is $X, 3;
41  {
42   local $X = 6;
43   is $X, 6;
44  }
45  is $X, 3;
46  {
47   local $X = 7;
48   set_temp $X => 8;
49   is $X, 8;
50  }
51  is $X, 3;
52  {
53   set_temp $X => 9;
54   local $X = 10;
55   is $X, 10;
56  }
57  is $X, 3;
58 }
59 is $X, 1;