chibi-scheme/tests
ilammy a1ec8ff493 Avoid overflow when doing sexp_fx_abs()
Naturally, fixed-width integer arithmetics can overflow. Chibi handles
it pretty well in general, but one case was missing: it is negation of
the minimal negative number that can be represented as a fixnum. That is,
sexp_fx_neg() must not be applied to sexp_make_fixnum(SEXP_MIN_FIXNUM)
because it overflows and returns an identical fixnum back.

sexp_fx_neg() itself seems to be used right in the current code, but
sexp_fx_abs()--which is defined in terms of sexp_fx_neg()--could be
applied to the forbidden number when used to retrieve an unboxed value
via the sexp_unbox_fixnum(sexp_fx_abs(x)) pattern. So I have added a
separate macro that safely calculates unboxed absolute value of a fixnum,
and replaced sexp_unbox_fixnum(sexp_fx_abs(x)) usages with it.

Current implementation uses two-bit tag for fixnums, plus we need one
bit for the sign, so fixnums have (machine word - 3) significant bits.
Regression tests cover word sizes of 16, 32, 64, and 128 bits (for the
sake of past- and future-proofness).

sexp_bignum_expt() does not have a regression test because we need to
check it with negative exponents like -2^29, so the base must be over
at least 2^(2^29) for the differences to be visible. Fun fact: bignum
representation of such number takes around 1/32 of the available user-
space memory, which makes testing on anything except 32-bit systems
unreasonable (4 TB of RAM anyone?)
2015-03-26 02:30:48 +02:00
..
basic Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
build Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
ffi Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
foreign Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
install Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
memory Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
base64-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
division-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
filesystem-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
flonum-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
generic-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
hash-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
io-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
iset-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
lib-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
loop-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
match-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
md5-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
memoize-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
mime-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
numeric-tests.scm Avoid overflow when doing sexp_fx_abs() 2015-03-26 02:30:48 +02:00
parse-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
path-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
prime-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
process-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
r5rs-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
r7rs-tests.scm Fixing typo in r7rs-tests. 2015-03-12 22:39:43 +09:00
re-tests.txt Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
record-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
regexp-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
rsa-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
scribble-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
sha-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
show-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
sort-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
srfi-1-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
srfi-2-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
srfi-16-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
srfi-26-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
srfi-27-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
srfi-33-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
srfi-38-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
string-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
system-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
tar-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
term-ansi-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
thread-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
unicode-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
uri-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
weak-tests.scm Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00