]> git.vpit.fr Git - perl/modules/Variable-Temp.git/blob - t/20-lvalue.t
90da2a98b24f520ef30cca056d04f06c1798af85
[perl/modules/Variable-Temp.git] / t / 20-lvalue.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use Variable::Temp 'temp';
7
8 use Test::More;
9
10 BEGIN {
11  if ("$]" >= 5.014) {
12   plan tests => 7 + 13;
13  } else {
14   plan skip_all => 'perl 5.14 required to lvalue assignment with prototype \[$@%]';
15  }
16 }
17
18 my $x = 1;
19 is $x, 1;
20 {
21  temp $x = 2;
22  is $x, 2;
23  $x = 3;
24  is $x, 3;
25  {
26   temp $x = 4;
27   is $x, 4;
28   temp $x = 5;
29   is $x, 5;
30  }
31  is $x, 3;
32 }
33 is $x, 1;
34
35 our $y = 1;
36 is $y, 1;
37 {
38  temp $y = 2;
39  is $y, 2;
40  $y = 3;
41  is $y, 3;
42  {
43   temp $y = 4;
44   is $y, 4;
45   temp $y = 5;
46   is $y, 5;
47  }
48  is $y, 3;
49  {
50   local $y = 6;
51   is $y, 6;
52  }
53  is $y, 3;
54  {
55   local $y = 7;
56   temp $y = 8;
57   is $y, 8;
58  }
59  is $y, 3;
60  {
61   temp $y = 9;
62   local $y = 10;
63   is $y, 10;
64  }
65  is $y, 3;
66 }
67 is $y, 1;