Subject: | "==" overloading is broken for "NaN" |
Hi,
This stems from a bug report filed in Authen::TypeKey (http://rt.cpan.org/NoAuth/Bug.html?id=15895).
The attached test shows that when comparing a "NaN" to a regular Math::BigInt, it returns true; though stringification shows otherwise.
Here's the output on my machine:
1..4
ok 1 - The object isa Math::BigInt
ok 2 - The object isa Math::BigInt
$VAR1 = bless( {
'value' => [
0
],
'sign' => 'NaN'
}, 'Math::BigInt' );
$VAR2 = bless( {
'value' => [
12345
],
'sign' => '+'
}, 'Math::BigInt' );
ok 3 - $value1 should not equal $value2 (stringified)
not ok 4 - $value1 should not equal $value2 (== overload)
# Failed test (bigint.t at line 13)
# Looks like you failed 1 test of 4.
I've added some warnings to show what the variables look like underneath.
-Brian
use Test::More tests => 4;
use Math::BigInt;
use Data::Dumper;
my $value1 = Math::BigInt->new( 'foo' );
isa_ok( $value1, 'Math::BigInt' );
my $value2 = Math::BigInt->new( 12345 );
isa_ok( $value2, 'Math::BigInt' );
warn Dumper $value1, $value2;
ok( !( "$value1" == "$value2" ), '$value1 should not equal $value2 (stringified)' );
ok( !( $value1 == $value2 ), '$value1 should not equal $value2 (== overload)' );