From: Vincent Pit Date: Sun, 28 Dec 2008 17:52:17 +0000 (+0100) Subject: Test incompletely tied arrays X-Git-Tag: v0.02~2 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FScope-Upper.git;a=commitdiff_plain;h=8025876416295c1957f9ece5d2770dd00e4d65a5 Test incompletely tied arrays --- 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;