X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F49-localize_delete-target.t;h=30468a1169ee13df4d85ae45c27ea5e435791769;hb=5327334c349244e4e8e49239528400902677075a;hp=6ddf79c79b1447fde93fbe10e55ea3037128e86f;hpb=e2ff531cb21aae759ad18f1e996e6f014ff5f3d0;p=perl%2Fmodules%2FScope-Upper.git diff --git a/t/49-localize_delete-target.t b/t/49-localize_delete-target.t index 6ddf79c..30468a1 100644 --- a/t/49-localize_delete-target.t +++ b/t/49-localize_delete-target.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 30; +use Test::More tests => 36; use Scope::Upper qw/localize_delete/; @@ -39,6 +39,34 @@ our @a; is_deeply \@a, [ 4 .. 6, undef, 7 ], 'localize_delete "@a", 4 (exists), 0 [end]'; } +{ + local @a = (4 .. 6); + { + localize_delete '@main::a', -2, 0; + is_deeply \@a, [ 4, undef, 6 ], 'localize_delete "@a", -2, 0 [ok]'; + } + is_deeply \@a, [ 4 .. 6 ], 'localize_delete "@a", -2, 0 [end]'; +} + +{ + local @a = (4 .. 6); + local $a[4] = 7; + { + localize_delete '@main::a', -1, 0; + is_deeply \@a, [ 4 .. 6 ], 'localize_delete "@a", -1 (exists), 0 [ok]'; + } + is_deeply \@a, [ 4 .. 6, undef, 7 ], 'localize_delete "@a", -1 (exists), 0 [end]'; +} + +{ + local @a = (4 .. 6); + { + eval { localize_delete '@main::a', -4, 0 }; + like $@, qr/Modification of non-creatable array value attempted, subscript -4/, 'localize_delete "@a", -4 (out of bounds), 0 [ok]'; + } + is_deeply \@a, [ 4 .. 6 ], 'localize_delete "@a", -4 (out of bounds), 0 [end]'; +} + { local @a = (4 .. 6); {