Skip Menu |

This queue is for tickets about the Tangence CPAN distribution.

Report information
The Basics
Id: 118806
Status: resolved
Priority: 0/
Queue: Tangence

People
Owner: Nobody in particular
Requestors: SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.22
Fixed in: 0.23



Subject: t/10message.t passes only with perl 5.22.x
t/10message.t passes only with perl 5.22.x and fails for older or newer perls, see http://fast-matrix.cpantesters.org/?dist=Tangence%200.22 Test log output with 5.20.x: # Failed test '$type->unpack_value float16 NaN' # at t/10message.t line 220. # got: 'nan' # expected: 'NaN' # Failed test '$type->unpack_value float16 oversize' # at t/10message.t line 220. # got: 'inf' # expected: 'Inf' # Failed test '$type->unpack_value float32 NaN' # at t/10message.t line 220. # got: 'nan' # expected: 'NaN' # Failed test '$type->unpack_value float64 NaN' # at t/10message.t line 220. # got: 'nan' # expected: 'NaN' # Looks like you failed 4 tests of 216. t/10message.t .......... Dubious, test returned 4 (wstat 1024, 0x400) Failed 4/216 subtests Test log output with perl 5.25.6 (freebsd 10): # Failed test 'pack typed float16 NaN' # at t/10message.t line 205. # at bytes 0-0xf (0-15) # got: | 10 fe 00 .. .. .. .. .. .. .. .. .. .. .. .. .. |... | # exp: | 10 7e 00 .. .. .. .. .. .. .. .. .. .. .. .. .. |.~. | # Failed test 'pack typed float32 NaN' # at t/10message.t line 205. # at bytes 0-0xf (0-15) # got: | 11 ff c0 00 00 .. .. .. .. .. .. .. .. .. .. .. |..... | # exp: | 11 7f c0 00 00 .. .. .. .. .. .. .. .. .. .. .. |..... | # Failed test 'pack typed float64 NaN' # at t/10message.t line 205. # at bytes 0-0xf (0-15) # got: | 12 ff f8 00 00 00 00 00 00 .. .. .. .. .. .. .. |......... | # exp: | 12 7f f8 00 00 00 00 00 00 .. .. .. .. .. .. .. |......... | # Failed test 'pack typed any (NaN)' # at t/10message.t line 205. # at bytes 0-0xf (0-15) # got: | 10 fe 00 .. .. .. .. .. .. .. .. .. .. .. .. .. |... | # exp: | 10 7e 00 .. .. .. .. .. .. .. .. .. .. .. .. .. |.~. | # Looks like you failed 4 tests of 216. t/10message.t .......... Dubious, test returned 4 (wstat 1024, 0x400) Failed 4/216 subtests
On Thu Nov 17 02:18:03 2016, SREZIC wrote: Show quoted text
> t/10message.t passes only with perl 5.22.x and fails for older or > newer perls, see http://fast- > matrix.cpantesters.org/?dist=Tangence%200.22
Ohhh, perl. :( Looks like I'll have to apply some stronger numification canonicalisation in the tests then. -- Paul Evans
On Thu Nov 17 17:32:07 2016, PEVANS wrote: Show quoted text
> On Thu Nov 17 02:18:03 2016, SREZIC wrote:
> > t/10message.t passes only with perl 5.22.x and fails for older or > > newer perls, see http://fast- > > matrix.cpantesters.org/?dist=Tangence%200.22
> > Ohhh, perl. :( > > Looks like I'll have to apply some stronger numification > canonicalisation in the tests then.
Turned out to be two separate bugs. Perls older than 5.22 had inconsistent stringification of NaN and Inf, requiring more canonicalisation in tests. Perls newer than 5.22 have changed the rules about NaN byte packing, always setting the sign bit. -- Paul Evans
Subject: rt118806.patch
=== modified file 'doc/Tangence.txt' --- doc/Tangence.txt 2016-11-16 22:23:25 +0000 +++ doc/Tangence.txt 2016-11-18 20:39:16 +0000 @@ -350,7 +350,7 @@ maximum allowed value. If the mantissa is zero this represents an infinity of the given sign, and if the mantissa is non-zero, it is a not-a-number value. For canonical identity, the non-zero mantissa should have only its top bit -set. +set, and the sign bit should be clear. Subtype Exponent Mantissa === modified file 'lib/Tangence/Type/Primitive.pm' --- lib/Tangence/Type/Primitive.pm 2016-11-16 16:17:02 +0000 +++ lib/Tangence/Type/Primitive.pm 2016-11-18 20:39:16 +0000 @@ -170,8 +170,9 @@ { my %format = ( - DATANUM_FLOAT32, [ "f>", 4 ], - DATANUM_FLOAT64, [ "d>", 8 ], + # pack, bytes, NaN + DATANUM_FLOAT32, [ "f>", 4, "\x7f\xc0\x00\x00" ], + DATANUM_FLOAT64, [ "d>", 8, "\x7f\xf8\x00\x00\x00\x00\x00\x00" ], ); sub _best_type_for @@ -218,7 +219,9 @@ return Tangence::Type::Primitive::float16->pack_value( $message, $value ) if $subtype == DATANUM_FLOAT16; $message->_pack_leader( DATA_NUMBER, $subtype ); - $message->_pack( pack( $format{$subtype}[0], $value ) ); + $message->_pack( $value == $value ? + pack( $format{$subtype}[0], $value ) : $format{$subtype}[2] + ); } sub unpack_value @@ -278,6 +281,7 @@ # special value - Inf or NaN $exp = 16; $mant16 = $mant32 ? (1 << 9) : 0; + $sign = 0 if $mant16; } elsif( $exp > 15 ) { # Too large - become Inf === modified file 't/10message.t' --- t/10message.t 2016-11-16 15:18:11 +0000 +++ t/10message.t 2016-11-18 19:58:25 +0000 @@ -211,7 +211,7 @@ # Approximate comparison for floats $_ = sprintf "%.5f", $_ for $expect, $value; } - elsif( defined $expect and $expect =~ m/^[+-]inf$/i ) { + elsif( defined $expect and $expect =~ m/^(?:[+-]inf|nan)$/i ) { # Canonicalise infinities $value = 0+$value; $expect = 0+$expect; @@ -343,7 +343,7 @@ sig => "float16", data => 1E12, stream => "\x10\x7c\x00", - retdata => "Inf"; + retdata => "+Inf"; test_typed "float32 zero", sig => "float32",
Should be fixed by 0.23 -- Paul Evans
On 2017-01-10 12:54:42, PEVANS wrote: Show quoted text
> Should be fixed by 0.23
Yes, the matrix looks much better now.