X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F38-localize_elem-magic.t;fp=t%2F38-localize_elem-magic.t;h=2754885a41aa7b04fa6412ec646690271ad5d103;hb=8025876416295c1957f9ece5d2770dd00e4d65a5;hp=2db3e2fe9da05a45c7d8ae3a8cb2472d61b74aba;hpb=1a52b3489cc6cdf5c139fc68828e7e0d6ae128fd;p=perl%2Fmodules%2FScope-Upper.git diff --git a/t/38-localize_elem-magic.t b/t/38-localize_elem-magic.t index 2db3e2f..2754885 100644 --- a/t/38-localize_elem-magic.t +++ b/t/38-localize_elem-magic.t @@ -5,7 +5,30 @@ use warnings; use Scope::Upper qw/localize_elem/; -use Test::More tests => 6; +use Test::More tests => 8; + +{ + package Scope::Upper::Test::TiedArray; + + sub TIEARRAY { bless [], $_[0] } + sub STORE { $_[0]->[$_[1]] = $_[2] } + sub FETCH { $_[0]->[$_[1]] } + sub CLEAR { @{$_[0]} = (); } + sub FETCHSIZE { scalar @{$_[0]} } + sub EXTEND {} +} + +our @a; + +tie @a, 'Scope::Upper::Test::TiedArray'; +{ + local @a = (5 .. 7); + { + localize_elem '@a', 4 => 12 => 0; + is_deeply \@a, [ 5 .. 7, undef, 12 ], 'localize_elem @incomplete_tied_array, $nonexistent, 12 => 0 [ok]'; + } + is_deeply \@a, [ 5 .. 7, undef, undef ], 'localize_elem @incomplete_tied_array, $nonexistent, 12 => 0 [end]'; +} our $x;