Subject: | is_deeply() dies with undef params |
Hiya,
is_deeply() dies when you pass a ref and undef (in either order) as the first two params. For example:
use Test::More 'no_plan';
warn "Test::More::VERSION = $Test::More::VERSION\n";
is_deeply( {}, undef, 'my hash is undef' );
prints:
$ perl t.pl
Test::More::VERSION = 0.54
not ok 1 - my hash is undef
# Failed test (t.pl at line 3)
Modification of non-creatable array value attempted, subscript -1 at
/usr/local/lib/perl5/5.8.5/Test/More.pm line 1068.
1..1
# Looks like you failed 1 test of 1.
# Looks like your test died just after 1.
The culprit is this line in Test::More:
my @vals = @{$Stack[-1]{vals}}[0,1];
Stepping through it with the debugger shows that @Stack is an empty list (it is passed in from @Data_Stack created in is_deeply() line 1033). It seems Perl doesn't (no longer?) auto-vivify array elements at -1:
DB<6> x \@{$Stack[-1]{vals}}[0,1];
Modification of non-creatable array value attempted,
subscript -1 at (eval 35)[/usr/local/lib/perl5/5.8.5/perl5db.pl:620] line 2.
But it does with elements at idx 0:
DB<3> x \@{$Stack[0]{vals}}[0,1];
0 SCALAR(0x855c18c)
-> undef
1 SCALAR(0x8579b48)
-> undef
Maybe this is a bug in Perl?
I'm running OS X 10.3 / perl-5.8.5.
-Steve