Fix stringification assumption bug in overload.t, revealed by ia64-linux-ld.
Nicholas Clark [Thu, 11 Mar 2010 14:08:07 +0000 (14:08 +0000)]
Specifically:
1: / returns and NV where possible, only returning an integer if the dividend
   is an integer larger than an NV can represent accurately, and integer
   division is exact (ie no fractional part/remainder).
2: The test is performing $ref/1, intending it to be an identity operation
   on the numeric value of the reference.
3: The test assumes that the return result of the division will be a number
   that stringifies identically to the integer value of the reference.

The fails if both:

1: The system memory map is such that addresses are very large (ia64 does)
2: NVs are large enough to hold these addresses

because then the address becomes converted to an NV which has sufficient
decimal digits that stringification defaults to scientific notation.

Itanium Linux users the world over will be cheering because they can now
compile Perl with long doubles with confidence that all tests pass.

lib/overload.t

index 39333cf..734e8b1 100644 (file)
@@ -1558,7 +1558,7 @@ foreach my $op (qw(<=> == != < <= > >=)) {
     is($m+$m, 2*$num_val, 'numifies to usual reference value');
     is(0-$m, -$num_val, 'numifies to usual reference value');
     is(1*$m, $num_val, 'numifies to usual reference value');
-    is($m/1, $num_val, 'numifies to usual reference value');
+    is(int($m/1), $num_val, 'numifies to usual reference value');
     is($m%100, $num_val%100, 'numifies to usual reference value');
     is($m**1, $num_val, 'numifies to usual reference value');
 
@@ -1569,7 +1569,7 @@ foreach my $op (qw(<=> == != < <= > >=)) {
     is($aref+$aref, 2*$num_val, 'ref addition');
     is(0-$aref, -$num_val, 'subtraction of ref');
     is(1*$aref, $num_val, 'multiplicaton of ref');
-    is($aref/1, $num_val, 'division of ref');
+    is(int($aref/1), $num_val, 'division of ref');
     is($aref%100, $num_val%100, 'modulo of ref');
     is($aref**1, $num_val, 'exponentiation of ref');
 }