X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FVariable-Temp.git;a=blobdiff_plain;f=t%2F20-lvalue.t;fp=t%2F20-lvalue.t;h=90da2a98b24f520ef30cca056d04f06c1798af85;hp=0000000000000000000000000000000000000000;hb=5320e49c16938a2a90a4f5ac55a1c8dd9482127b;hpb=5a4659ac8f3724ea57a8a2cf5ccf32f6e66ead22 diff --git a/t/20-lvalue.t b/t/20-lvalue.t new file mode 100644 index 0000000..90da2a9 --- /dev/null +++ b/t/20-lvalue.t @@ -0,0 +1,67 @@ +#!perl -T + +use strict; +use warnings; + +use Variable::Temp 'temp'; + +use Test::More; + +BEGIN { + if ("$]" >= 5.014) { + plan tests => 7 + 13; + } else { + plan skip_all => 'perl 5.14 required to lvalue assignment with prototype \[$@%]'; + } +} + +my $x = 1; +is $x, 1; +{ + temp $x = 2; + is $x, 2; + $x = 3; + is $x, 3; + { + temp $x = 4; + is $x, 4; + temp $x = 5; + is $x, 5; + } + is $x, 3; +} +is $x, 1; + +our $y = 1; +is $y, 1; +{ + temp $y = 2; + is $y, 2; + $y = 3; + is $y, 3; + { + temp $y = 4; + is $y, 4; + temp $y = 5; + is $y, 5; + } + is $y, 3; + { + local $y = 6; + is $y, 6; + } + is $y, 3; + { + local $y = 7; + temp $y = 8; + is $y, 8; + } + is $y, 3; + { + temp $y = 9; + local $y = 10; + is $y, 10; + } + is $y, 3; +} +is $y, 1;