From: Vincent Pit Date: Wed, 1 Apr 2015 12:40:46 +0000 (-0300) Subject: Improve basic scalar tests X-Git-Tag: v0.02~5 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=dc891c289e47d178a3312b13482753c964e3da00;p=perl%2Fmodules%2FVariable-Temp.git Improve basic scalar tests --- diff --git a/t/10-base.t b/t/10-base.t index f5fb397..701cead 100644 --- a/t/10-base.t +++ b/t/10-base.t @@ -5,7 +5,7 @@ use warnings; use Variable::Temp 'set_temp'; -use Test::More tests => (7 + 2 * 19) * 2 + 6 * 3; +use Test::More tests => (9 + 2 * 19) * 2 + 6 * 3; sub describe { my $h = $_[0]; @@ -14,22 +14,29 @@ sub describe { # Lexicals -my $x = 1; -is $x, 1; { - set_temp $x => 2; - is $x, 2; - $x = 3; - is $x, 3; + my $x = 1; + is $x, 1; + { + set_temp $x => 2; + is $x, 2; + $x = 3; + is $x, 3; + } + is $x, 1; { set_temp $x => 4; is $x, 4; set_temp $x => 5; is $x, 5; } - is $x, 3; + is $x, 1; + { + set_temp $x; + is $x, undef; + } + is $x, 1; } -is $x, 1; { my @y = (1, 2); @@ -129,39 +136,46 @@ is $x, 1; # Globals -our $X = 1; -is $X, 1; { - set_temp $X => 2; - is $X, 2; - $X = 3; - is $X, 3; + our $X = 1; + is $X, 1; + { + set_temp $X => 2; + is $X, 2; + $X = 3; + is $X, 3; + } + is $X, 1; { set_temp $X => 4; is $X, 4; set_temp $X => 5; is $X, 5; } - is $X, 3; + is $X, 1; + { + set_temp $X; + is $X, undef; + } + is $X, 1; { local $X = 6; is $X, 6; } - is $X, 3; + is $X, 1; { local $X = 7; set_temp $X => 8; is $X, 8; } - is $X, 3; + is $X, 1; { set_temp $X => 9; local $X = 10; is $X, 10; } - is $X, 3; + is $X, 1; } -is $X, 1; { our @Y = (1, 2);