chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] [PATCH] Fix inconsistency between core test lib and te


From: Peter Bex
Subject: [Chicken-hackers] [PATCH] Fix inconsistency between core test lib and test egg, and fix number->string conversion on some edge case flonums
Date: Mon, 16 Oct 2017 20:54:03 +0200
User-agent: NeoMutt/20170113 (1.7.2)

Hi all,

I just discovered something weird and annoying: the (test-end) in
the core version of test.scm behaves differently from the test egg!
In the test egg, (test-begin) and (test-end) are an alternate,
non-nesting syntax for (test-group), but in the core version, (test-end)
behaves like (test-exit) from the test egg.

This means that there are several tests which didn't really get tested
all the way through, especially the tests taken from the numbers egg
and irregex.

The first of the attached patches fixes the tests.  This exposed an
issue with how flonums are serialized by the compiler (and also in
the repl), because the numbers-test-gauche now failed.
Try it: (print (expt 2.0 64.0)) will print 0.0 (but it won't be
equal to 0.0)  The second patch fixes this issue; the commit message
explains the gory details.

I don't know whether we should also fix the helper function in master;
the number->string conversion there uses a different approach so it
is not affected by this specific bug, but u32vectors will allow you to
put a value like (expt 2.0 64.0) in the vector without giving an error,
and the effect is that the value will be zero.  Actually, the code is
wildly incorrect anyway for 64-bit platforms as it doesn't verify that
the number fits an unsigned integer, but it verifies that the number
fits a machine word, which is an unsigned long on 64 bit platforms.

The fix for master would be pretty straightforward: just replace
C_[U]WORD_MAX and C_WORD_MIN by [U]INT_MAX and INT_MIN in
C_fits_in_int_p and C_fits_in_unsigned_int_p.  I don't know if there's
any code around that actually relies on this checking whether the
number fits a _word_, instead, though.

Cheers,
Peter

Attachment: 0001-Fix-test-end-to-not-end-the-entire-process-but-the-c.patch
Description: Text Data

Attachment: 0002-Fix-flonum-to-string-conversion-on-extreme-edge-case.patch
Description: Text Data

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]