Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Test-Simple CPAN distribution.

Report information
The Basics
Id: 9441
Status: resolved
Priority: 0/
Queue: Test-Simple

People
Owner: Nobody in particular
Requestors: steve [...] purkis.ca
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.54
Fixed in: (no value)



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
From: cpan [...] ali.as
Looking at the code at bottom, there's absolutely no reason whatsoever to have to do a _deep_check, having already detected that they arn't the same. $ok = 0; ... could just become $ok = $Test->ok(0, $name); $ok = $Test->diag(_format_stack( { vals => [ $this, $that ] }, )); return $ok; -------------------------------------------------------- my $ok; if( !ref $this xor !ref $that ) { # one's a reference, one isn't $ok = 0; } if( !ref $this and !ref $that ) { $ok = $Test->is_eq($this, $that, $name); } else { local @Data_Stack = (); local %Refs_Seen = (); if( _deep_check($this, $that) ) { $ok = $Test->ok(1, $name); } else { $ok = $Test->ok(0, $name); $ok = $Test->diag(_format_stack(@Data_Stack)); } } return $ok;