summaryrefslogtreecommitdiff
path: root/t/op/pack.t
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2002-06-29 19:24:08 +0100
committerJarkko Hietaniemi <jhi@iki.fi>2002-06-30 01:22:05 +0000
commit203d3f29cd3ae9183e6599d2513c004ec3fdd9ee (patch)
treee4500525f83ca7ea3a9c5ab41ddf292746a2b61b /t/op/pack.t
parent7d7d56956ffccd7e55408c3bd48a31d5bf524b49 (diff)
downloadperl-203d3f29cd3ae9183e6599d2513c004ec3fdd9ee.tar.gz
Re: [PATCH] pack 'w' should be using NV, not double
Message-ID: <20020629172408.GB322@Bagpuss.unfortu.net> p4raw-id: //depot/perl@17382
Diffstat (limited to 't/op/pack.t')
-rwxr-xr-xt/op/pack.t19
1 files changed, 18 insertions, 1 deletions
diff --git a/t/op/pack.t b/t/op/pack.t
index ca5ab4a43d..1661da5764 100755
--- a/t/op/pack.t
+++ b/t/op/pack.t
@@ -6,7 +6,7 @@ BEGIN {
require './test.pl';
}
-plan tests => 5816;
+plan tests => 5819;
use strict;
use warnings;
@@ -139,6 +139,23 @@ sub list_eq ($$) {
}
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);
}