]> git.vpit.fr Git - perl/modules/Variable-Temp.git/blob - t/20-lvalue.t
'temp $scalar;' should undef $scalar
[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 => 9 + 15;
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  temp $x;
36  is $x, undef;
37 }
38 is $x, 1;
39
40 our $y = 1;
41 is $y, 1;
42 {
43  temp $y = 2;
44  is $y, 2;
45  $y = 3;
46  is $y, 3;
47  {
48   temp $y = 4;
49   is $y, 4;
50   temp $y = 5;
51   is $y, 5;
52  }
53  is $y, 3;
54  {
55   local $y = 6;
56   is $y, 6;
57  }
58  is $y, 3;
59  {
60   local $y = 7;
61   temp $y = 8;
62   is $y, 8;
63  }
64  is $y, 3;
65  {
66   temp $y = 9;
67   local $y = 10;
68   is $y, 10;
69  }
70  is $y, 3;
71 }
72 is $y, 1;
73 {
74  temp $y;
75  is $y, undef;
76 }
77 is $y, 1;