This once again does NOT compile. I've done work on macros; they don't work yet..
This commit is contained in:
parent
e3f922a8bf
commit
2b22780ccf
86 changed files with 279 additions and 153 deletions
278
unit-tests/bignum-add.sh
Executable file
278
unit-tests/bignum-add.sh
Executable file
|
|
@ -0,0 +1,278 @@
|
|||
#!/bin/bash
|
||||
|
||||
return=0
|
||||
|
||||
#####################################################################
|
||||
# add two large numbers, not actally bignums to produce a smallnum
|
||||
# (right on the boundary)
|
||||
a=1152921504606846975
|
||||
b=1
|
||||
c=`echo "$a + $b" | bc`
|
||||
expected='t'
|
||||
output=`echo "(= (+ $a $b) $c)" | target/psse -v 2 2>tmp/psse.log`
|
||||
|
||||
actual=`echo $output |\
|
||||
tail -1`
|
||||
|
||||
echo -n "$0 => adding $a to $b: "
|
||||
if [ "${expected}" = "${actual}" ]
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Fail: expected '${expected}', got '${actual}'"
|
||||
return=`echo "${return} + 1" | bc`
|
||||
fi
|
||||
|
||||
echo -n "$0: checking no bignum was created: "
|
||||
grep -v 'BIGNUM!' tmp/psse.log > /dev/null
|
||||
if [ $? -eq "0" ]
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Fail"
|
||||
return=`echo "${return} + 1" | bc`
|
||||
fi
|
||||
|
||||
#####################################################################
|
||||
# add two numbers, not actally bignums to produce a bignum
|
||||
# (just over the boundary)
|
||||
a='1152921504606846976'
|
||||
b=1
|
||||
c=`echo "$a + $b" | bc`
|
||||
expected='t'
|
||||
output=`echo "(= (+ $a $b) $c)" | target/psse -v 2 2>tmp/psse.log`
|
||||
|
||||
actual=`echo $output |\
|
||||
tail -1 |\
|
||||
sed 's/\,//g'`
|
||||
|
||||
echo -n "$0 => adding $a to $b: "
|
||||
if [ "${expected}" = "${actual}" ]
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Fail: expected '${expected}', got '${actual}'"
|
||||
return=`echo "${return} + 1" | bc`
|
||||
fi
|
||||
|
||||
echo -n "$0 => checking a bignum was created: "
|
||||
grep 'BIGNUM!' tmp/psse.log > /dev/null
|
||||
if [ $? -eq "0" ]
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Fail"
|
||||
return=`echo "${return} + 1" | bc`
|
||||
fi
|
||||
|
||||
|
||||
#####################################################################
|
||||
# add a bignum and a smallnum to produce a bignum
|
||||
# (just over the boundary)
|
||||
a='1152921504606846977'
|
||||
b=1
|
||||
c=`echo "$a + $b" | bc`
|
||||
expected='t'
|
||||
output=`echo "(= (+ $a $b) $c)" | target/psse -v 2 2>tmp/psse.log`
|
||||
|
||||
actual=`echo $output |\
|
||||
tail -1 |\
|
||||
sed 's/\,//g'`
|
||||
|
||||
echo -n "$0 => adding $a to $b: "
|
||||
if [ "${expected}" = "${actual}" ]
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Fail: expected '${expected}', got '${actual}'"
|
||||
return=`echo "${return} + 1" | bc`
|
||||
fi
|
||||
|
||||
echo -n "$0 => checking a bignum was created: "
|
||||
grep 'BIGNUM!' tmp/psse.log > /dev/null
|
||||
if [ $? -eq "0" ]
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Fail"
|
||||
return=`echo "${return} + 1" | bc`
|
||||
fi
|
||||
|
||||
#####################################################################
|
||||
# add a smallnum and a bignum to produce a bignum
|
||||
# (just over the boundary)
|
||||
|
||||
a=1
|
||||
b=1152921504606846977
|
||||
c=`echo "$a + $b" | bc`
|
||||
expected='t'
|
||||
output=`echo "(= (+ $a $b) $c)" | target/psse -v 2 2>tmp/psse.log`
|
||||
|
||||
actual=`echo $output |\
|
||||
tail -1 |\
|
||||
sed 's/\,//g'`
|
||||
|
||||
echo -n "$0 => adding $a to $b: "
|
||||
if [ "${expected}" = "${actual}" ]
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Fail: expected '${expected}', got '${actual}'"
|
||||
return=`echo "${return} + 1" | bc`
|
||||
fi
|
||||
|
||||
echo -n "$0 => checking a bignum was created: "
|
||||
grep 'BIGNUM!' tmp/psse.log > /dev/null
|
||||
if [ $? -eq "0" ]
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Fail"
|
||||
return=`echo "${return} + 1" | bc`
|
||||
fi
|
||||
|
||||
|
||||
#####################################################################
|
||||
# add two small bignums to produce a bigger bignum
|
||||
|
||||
a=1152921504606846977
|
||||
c=`echo "$a + $a" | bc`
|
||||
echo -n "$0 => adding $a to $a: "
|
||||
expected='t'
|
||||
output=`echo "(= (+ $a $b) $c)" | target/psse -v 2 2>tmp/psse.log`
|
||||
|
||||
actual=`echo $output |\
|
||||
tail -1 |\
|
||||
sed 's/\,//g'`
|
||||
|
||||
if [ "${expected}" = "${actual}" ]
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Fail: expected '${expected}', got '${actual}'"
|
||||
return=`echo "${return} + 1" | bc`
|
||||
fi
|
||||
|
||||
#####################################################################
|
||||
# add five small bignums to produce a bigger bignum
|
||||
|
||||
a=1152921504606846977
|
||||
c=`echo "$a * 5" | bc`
|
||||
echo -n "$0 => adding $a, $a $a, $a, $a: "
|
||||
expected='t'
|
||||
output=`echo "(= (+ $a $a $a $a $a) $c)" | target/psse -v 2 2>tmp/psse.log`
|
||||
|
||||
actual=`echo $output |\
|
||||
tail -1 |\
|
||||
sed 's/\,//g'`
|
||||
|
||||
if [ "${expected}" = "${actual}" ]
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Fail: expected '${expected}', got '${actual}'"
|
||||
return=`echo "${return} + 1" | bc`
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
#####################################################################
|
||||
# add two bignums to produce a bignum
|
||||
a=10000000000000000000
|
||||
b=10000000000000000000
|
||||
c=`echo "$a + $b" | bc`
|
||||
expected='t'
|
||||
output=`echo "(= (+ $a $b) $c)" | target/psse -v 2 2>tmp/psse.log`
|
||||
|
||||
actual=`echo $output |\
|
||||
tail -1 |\
|
||||
sed 's/\,//g'`
|
||||
|
||||
echo -n "$0 => adding $a to $b: "
|
||||
if [ "${expected}" = "${actual}" ]
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Fail: expected '${expected}', got '${actual}'"
|
||||
return=`echo "${return} + 1" | bc`
|
||||
fi
|
||||
|
||||
echo -n "$0 => checking a bignum was created: "
|
||||
grep 'BIGNUM!' tmp/psse.log > /dev/null
|
||||
if [ $? -eq "0" ]
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Fail"
|
||||
return=`echo "${return} + 1" | bc`
|
||||
fi
|
||||
|
||||
|
||||
#####################################################################
|
||||
# add a smallnum and a two-cell bignum to produce a three-cell bignum
|
||||
# (just over the boundary)
|
||||
a=1
|
||||
b=1329227995784915872903807060280344576
|
||||
c=`echo "$a + $b" | bc`
|
||||
expected='t'
|
||||
output=`echo "(= (+ $a $b) $c)" | target/psse -v 2 2>tmp/psse.log`
|
||||
|
||||
actual=`echo $output |\
|
||||
tail -1 |\
|
||||
sed 's/\,//g'`
|
||||
|
||||
echo -n "$0 => adding $a to $b: "
|
||||
if [ "${expected}" = "${actual}" ]
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Fail: expected '${expected}', got '${actual}'"
|
||||
return=`echo "${return} + 1" | bc`
|
||||
fi
|
||||
|
||||
echo -n "$0 => checking a bignum was created: "
|
||||
grep 'BIGNUM!' tmp/psse.log > /dev/null
|
||||
if [ $? -eq "0" ]
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Fail"
|
||||
return=`echo "${return} + 1" | bc`
|
||||
fi
|
||||
|
||||
|
||||
#####################################################################
|
||||
# This currently fails:
|
||||
# (= (+ 1 3064991081731777716716694054300618367237478244367204352)
|
||||
# 3064991081731777716716694054300618367237478244367204353)
|
||||
a=1
|
||||
b=3064991081731777716716694054300618367237478244367204352
|
||||
c=`echo "$a + $b" | bc`
|
||||
expected='t'
|
||||
output=`echo "(= (+ $a $b) $c)" | target/psse -v 2 2>tmp/psse.log`
|
||||
|
||||
actual=`echo $output |\
|
||||
tail -1 |\
|
||||
sed 's/\,//g'`
|
||||
|
||||
echo -n "$0 => adding $a to $b: "
|
||||
if [ "${expected}" = "${actual}" ]
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Fail: expected '${expected}', got '${actual}'"
|
||||
return=`echo "${return} + 1" | bc`
|
||||
fi
|
||||
|
||||
echo -n "$0 => checking a bignum was created: "
|
||||
grep 'BIGNUM!' tmp/psse.log > /dev/null
|
||||
if [ $? -eq "0" ]
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Fail"
|
||||
return=`echo "${return} + 1" | bc`
|
||||
fi
|
||||
|
||||
exit ${return}
|
||||
Loading…
Add table
Add a link
Reference in a new issue