if ($ry eq 'ARRAY') {
if ($#$x == $#$y) {
- _deep_check($x->[$_], $y->[$_]) or return 0 for 0 .. $#$y;
+ # Prevent vivification of deleted elements by fetching the array values.
+ my ($ex, $ey);
+ _deep_check($ex = $x->[$_], $ey = $y->[$_]) or return 0 for 0 .. $#$x;
return 1;
}
} elsif ($ry eq 'HASH') {
use strict;
use warnings;
-use Test::Leaner tests => 21 + 2 + 1;
+use Test::Leaner tests => 21 + 2 + 1 + 2;
my $lacunary = [ [ 1, 2, 3 ] => [ 1, 2, 3 ] ];
delete $lacunary->[0]->[1];
for my $t (@tests) {
is_deeply $t->[0], $t->[1];
}
+
+# Test vivification of deleted elements of an array
+
+{
+ my @l = (1);
+ $l[2] = 3;
+ is_deeply \@l, [ 1, undef, 3 ];
+ delete $l[2];
+ is_deeply \@l, [ 1 ];
+}