Added unit tests to establish that bignum addition and print work
the bug must be in multiplication.
This commit is contained in:
parent
7f93b04b72
commit
c209abb4f9
5 changed files with 355 additions and 8 deletions
57
unit-tests/bignum-print.sh
Normal file
57
unit-tests/bignum-print.sh
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#!/bin/bash
|
||||
|
||||
#####################################################################
|
||||
# large number, not actally a bignum
|
||||
expected='576460752303423488'
|
||||
output=`echo "(progn (print $expected) nil)" | target/psse`
|
||||
|
||||
actual=`echo $output |\
|
||||
sed 's/\,//g' |\
|
||||
sed 's/[^0-9]*\([0-9]*\).*/\1/'`
|
||||
|
||||
echo -n "printing $expected: "
|
||||
if [ "${expected}" = "${actual}" ]
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Fail: expected '${expected}', got '${actual}'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#####################################################################
|
||||
# right on the boundary
|
||||
expected='1152921504606846976'
|
||||
output=`echo "(progn (print $expected) nil)" | target/psse`
|
||||
|
||||
actual=`echo $output |\
|
||||
sed 's/\,//g' |\
|
||||
sed 's/[^0-9]*\([0-9]*\).*/\1/'`
|
||||
|
||||
echo -n "printing $expected: "
|
||||
if [ "${expected}" = "${actual}" ]
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Fail: expected '${expected}', got '${actual}'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#####################################################################
|
||||
# definitely a bignum
|
||||
expected='2305843009213693952'
|
||||
output=`echo "(progn (print $expected) nil)" | target/psse`
|
||||
|
||||
actual=`echo $output |\
|
||||
sed 's/\,//g' |\
|
||||
sed 's/[^0-9]*\([0-9]*\).*/\1/'`
|
||||
|
||||
echo -n "printing $expected: "
|
||||
if [ "${expected}" = "${actual}" ]
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Fail: expected '${expected}', got '${actual}'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue