From: Nicholas Clark Date: Sat, 29 Jun 2002 18:24:08 +0000 (+0100) Subject: Re: [PATCH] pack 'w' should be using NV, not double X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=203d3f29cd3ae9183e6599d2513c004ec3fdd9ee;p=p5sagit%2Fp5-mst-13.2.git Re: [PATCH] pack 'w' should be using NV, not double Message-ID: <20020629172408.GB322@Bagpuss.unfortu.net> p4raw-id: //depot/perl@17382 --- diff --git a/t/op/pack.t b/t/op/pack.t index ca5ab4a..1661da5 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); }