develooper Front page | perl.perl5.porters | Postings from June 2002

[PATCH] Re: [PATCH] pack 'w' should be using NV, not double

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
June 29, 2002 10:32
Subject:
[PATCH] Re: [PATCH] pack 'w' should be using NV, not double
Message ID:
20020629172408.GB322@Bagpuss.unfortu.net
On Wed, May 29, 2002 at 03:38:41PM +0100, Nicholas Clark wrote:
> I'm finding it very hard to make a regression test that fails for this
> one on a normal long double/use64bitint build. I can get t/op/pack.t

This test passes everywhere, but does fail on perl pre 16861 on x86 configured
with long doubles (and 32 bit ints)

Nicholas Clark
-- 
Even better than the real thing:	http://nms-cgi.sourceforge.net/

--- t/op/pack.t.orig	Wed May 29 09:22:41 2002
+++ t/op/pack.t	Fri Jun 28 14:34:22 2002
@@ -6,7 +6,7 @@
     require './test.pl';
 }
 
-plan tests => 5816;
+plan tests => 5819;
 
 use strict;
 use warnings;
@@ -139,6 +139,23 @@
     }
     cmp_ok(unpack ('w',$x), '==', ~0 - 1);
     cmp_ok(unpack ('w',$y), '==', ~0 - 2);
+
+    # These should spot that pack 'w' is using NV, not double, on platforms
+    # where IVs are smaller than doubles, and harmlessly pass elsewhere.
+    # (tests for change 16861)
+    my $x0 = 2**54+3;
+    my $y0 = 2**54-2;
+
+    $x = pack 'w', $x0;
+    $y = pack 'w', $y0;
+
+    if ($x0 == $y0) {
+        is($x, $y, "NV arithmetic");
+    } else {
+        isnt($x, $y, "IV/NV arithmetic");
+    }
+    cmp_ok(unpack ('w',$x), '==', $x0);
+    cmp_ok(unpack ('w',$y), '==', $y0);
 }
 
 

Thread Previous | 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