]> git.vpit.fr Git - perl/modules/Variable-Temp.git/blob - t/11-global.t
Use set_temp() in tests instead of temp()
[perl/modules/Variable-Temp.git] / t / 11-global.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use Variable::Temp 'set_temp';
7
8 use Test::More tests => 13;
9
10 our $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   local $x = 6;
26   is $x, 6;
27  }
28  is $x, 3;
29  {
30   local $x = 7;
31   set_temp $x => 8;
32   is $x, 8;
33  }
34  is $x, 3;
35  {
36   set_temp $x => 9;
37   local $x = 10;
38   is $x, 10;
39  }
40  is $x, 3;
41 }
42 is $x, 1;