From: Vincent Pit Date: Fri, 13 Mar 2015 19:02:57 +0000 (-0300) Subject: Test temp() in t/20-lvalue.t X-Git-Tag: v0.02~10 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=5320e49c16938a2a90a4f5ac55a1c8dd9482127b;p=perl%2Fmodules%2FVariable-Temp.git Test temp() in t/20-lvalue.t --- diff --git a/MANIFEST b/MANIFEST index d6ffc1e..088435c 100644 --- a/MANIFEST +++ b/MANIFEST @@ -11,4 +11,5 @@ t/10-base.t t/12-destroy.t t/13-magic.t t/15-lvalue-sub.t +t/20-lvalue.t t/lib/VPIT/TestHelpers.pm 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;