develooper Front page | perl.perl5.porters | Postings from November 2004

[perl #30576] Test::More thinks "" eq undef in hash value

Thread Next
From:
Steve Peters via RT
Date:
November 24, 2004 04:38
Subject:
[perl #30576] Test::More thinks "" eq undef in hash value
Message ID:
rt-3.0.11-30576-100931.0.336431142680453@perl.org
> [matthewg - Sat Jul 03 19:50:48 2004]:
> 
> This is a bug report for perl from matthewg@zevils.com,
> generated with the help of perlbug 1.35 running under perl v5.8.4.
> 
> 
> -----------------------------------------------------------------
> Test::More returns success for the following test:
> 	is_deeply({x => ""}, {x => undef});
> 
> A patch to correct the fix is attached.  The aforementioned test
>    should
> be added to the module's test suite to prevent regression.
> 
> 
> 

This bug still exists in Test::Simple 0.51.  

> perl -e'use Test::More qw(no_plan);print "$Test::More::VERSION\n";
print is_deeply({x=>""}, {x=>undef})'
0.51
ok 1
11..1

The following patch included in the original ticket and at the end of
http://rt.cpan.org/NoAuth/Bug.html?id=6837 also still fix the problem,
although the line numbers are a bit off.  Here's an updated version.  

--- /usr/libdata/perl5/Test/More.pm     Tue Nov 23 03:51:01 2004
+++ ./More.pm   Wed Nov 24 06:33:25 2004
@@ -1083,7 +1083,7 @@
         # Quiet uninitialized value warnings when comparing undefs.
         local $^W = 0;

-        if( $e1 eq $e2 ) {
+        if( (defined($e1) == defined($e2)) and $e1 eq $e2 ) {
             $ok = 1;
         }
         else {




Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About