X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F39-localize_elem-target.t;h=fe538e40ddb7ff92cfb6be93982f0cfcee2d114f;hb=bb65dbcf7daba3ac5c7e0f933745762bf6ea56bf;hp=ecff42bb2ab765847e25e74b89561ac4075cef50;hpb=1a52b3489cc6cdf5c139fc68828e7e0d6ae128fd;p=perl%2Fmodules%2FScope-Upper.git diff --git a/t/39-localize_elem-target.t b/t/39-localize_elem-target.t index ecff42b..fe538e4 100644 --- a/t/39-localize_elem-target.t +++ b/t/39-localize_elem-target.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 17; +use Test::More tests => 21; use Scope::Upper qw/localize_elem/; @@ -29,6 +29,24 @@ our @a; is_deeply \@a, [ 4 .. 6 ], 'localize_elem "@a", 4, 8, 0 [end]'; } +{ + local @a = (4 .. 6); + { + localize_elem '@main::a', -2, 8, 0; + is_deeply \@a, [ 4, 8, 6 ], 'localize_elem "@a", -2, 8, 0 [ok]'; + } + is_deeply \@a, [ 4 .. 6 ], 'localize_elem "@a", -2, 8, 0 [end]'; +} + +{ + local @a = (4 .. 6); + { + eval { localize_elem '@main::a', -4, 8, 0 }; + like $@, qr/Modification of non-creatable array value attempted, subscript -4/, 'localize_elem "@a", -4, 8, 0 [ok]'; + } + is_deeply \@a, [ 4 .. 6 ], 'localize_elem "@a", -4, 8, 0 [end]'; +} + { local @a = (4 .. 6); {