From 127f9b357854626e8263b1b00898128dfee4ddc1 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 22 Feb 2009 19:41:47 -0600 Subject: [PATCH] Add unit tests for bignum bug --- basis/math/bits/bits-tests.factor | 17 ++++++++++++++++- basis/math/functions/functions-tests.factor | 14 ++++++++++++++ .../math/miller-rabin/miller-rabin-tests.factor | 3 ++- core/math/integers/integers-tests.factor | 2 ++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/basis/math/bits/bits-tests.factor b/basis/math/bits/bits-tests.factor index 0503d27f33..ed4e8419c9 100644 --- a/basis/math/bits/bits-tests.factor +++ b/basis/math/bits/bits-tests.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2009 Daniel Ehrenberg ! See http://factorcode.org/license.txt for BSD license. -USING: tools.test math.bits sequences arrays ; +USING: tools.test math math.bits sequences arrays ; IN: math.bits.tests [ t ] [ BIN: 111111 3 second ] unit-test @@ -14,3 +14,18 @@ IN: math.bits.tests [ 2 ] [ -3 make-bits length ] unit-test [ 1 ] [ 1 make-bits length ] unit-test [ 1 ] [ -1 make-bits length ] unit-test + +! Odd bug +[ t ] [ + 1067811677921310779 make-bits + 1067811677921310779 >bignum make-bits + sequence= +] unit-test + +[ t ] [ + 1067811677921310779 make-bits peek +] unit-test + +[ t ] [ + 1067811677921310779 >bignum make-bits peek +] unit-test \ No newline at end of file diff --git a/basis/math/functions/functions-tests.factor b/basis/math/functions/functions-tests.factor index cf0ce5f0bb..9f5ce36be1 100644 --- a/basis/math/functions/functions-tests.factor +++ b/basis/math/functions/functions-tests.factor @@ -137,3 +137,17 @@ IN: math.functions.tests [ 6 59967 ] [ 3837888 factor-2s ] unit-test [ 6 -59967 ] [ -3837888 factor-2s ] unit-test + +[ 1 ] [ + 183009416410801897 + 1067811677921310779 + 2135623355842621559 + ^mod +] unit-test + +[ 1 ] [ + 183009416410801897 + 1067811677921310779 + 2135623355842621559 + [ >bignum ] tri@ ^mod +] unit-test \ No newline at end of file diff --git a/basis/math/miller-rabin/miller-rabin-tests.factor b/basis/math/miller-rabin/miller-rabin-tests.factor index 9ca85ea72c..5f1b9835e4 100644 --- a/basis/math/miller-rabin/miller-rabin-tests.factor +++ b/basis/math/miller-rabin/miller-rabin-tests.factor @@ -7,4 +7,5 @@ IN: math.miller-rabin.tests [ f ] [ 36 miller-rabin ] unit-test [ t ] [ 37 miller-rabin ] unit-test [ 101 ] [ 100 next-prime ] unit-test -[ 100000000000031 ] [ 100000000000000 next-prime ] unit-test +[ t ] [ 2135623355842621559 miller-rabin ] unit-test +[ 100000000000031 ] [ 100000000000000 next-prime ] unit-test \ No newline at end of file diff --git a/core/math/integers/integers-tests.factor b/core/math/integers/integers-tests.factor index 5a649120a0..6bd3e9b094 100644 --- a/core/math/integers/integers-tests.factor +++ b/core/math/integers/integers-tests.factor @@ -91,6 +91,8 @@ unit-test [ f ] [ BIN: -1101 >bignum 3 bit? ] unit-test [ t ] [ BIN: -1101 >bignum 4 bit? ] unit-test +[ t ] [ 1067811677921310779 >bignum 59 bit? ] unit-test + [ 2 ] [ 0 next-power-of-2 ] unit-test [ 2 ] [ 1 next-power-of-2 ] unit-test [ 2 ] [ 2 next-power-of-2 ] unit-test