Mainly unit tests. 39/45 currently pass; the failures are all in bignum arithmetic and in deallocation.

This commit is contained in:
Simon Brooke 2026-02-03 21:47:25 +00:00
parent e41ae1aa8b
commit e489d02069
21 changed files with 206 additions and 100 deletions

View file

@ -1,5 +1,7 @@
#!/bin/bash
return=0
#####################################################################
# add two large numbers, not actally bignums to produce a smallnum
# (right on the boundary)
@ -12,13 +14,13 @@ output=`echo "(= (+ $a $b) $c)" | target/psse -v 2 2>psse.log`
actual=`echo $output |\
tail -1`
echo -n "adding $a to $b: "
echo -n "$0 => adding $a to $b: "
if [ "${expected}" = "${actual}" ]
then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
return=1
fi
echo -n "checking no bignum was created: "
@ -28,7 +30,7 @@ then
echo "OK"
else
echo "Fail"
exit 1
return=1
fi
#####################################################################
@ -44,23 +46,23 @@ actual=`echo $output |\
tail -1 |\
sed 's/\,//g'`
echo -n "adding $a to $b: "
echo -n "$0 => adding $a to $b: "
if [ "${expected}" = "${actual}" ]
then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
return=1
fi
echo -n "checking a bignum was created: "
echo -n "$0 => checking a bignum was created: "
grep 'BIGNUM!' psse.log > /dev/null
if [ $? -eq "0" ]
then
echo "OK"
else
echo "Fail"
exit 1
return=1
fi
@ -77,28 +79,29 @@ actual=`echo $output |\
tail -1 |\
sed 's/\,//g'`
echo -n "adding $a to $b: "
echo -n "$0 => adding $a to $b: "
if [ "${expected}" = "${actual}" ]
then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
return=1
fi
echo -n "checking a bignum was created: "
echo -n "$0 => checking a bignum was created: "
grep 'BIGNUM!' psse.log > /dev/null
if [ $? -eq "0" ]
then
echo "OK"
else
echo "Fail"
exit 1
return=1
fi
#####################################################################
# add a smallnum and a bignum to produce a bignum
# (just over the boundary)
a=1
b=1152921504606846977
c=`echo "$a + $b" | bc`
@ -109,13 +112,13 @@ actual=`echo $output |\
tail -1 |\
sed 's/\,//g'`
echo -n "adding $a to $b: "
echo -n "$0 => adding $a to $b: "
if [ "${expected}" = "${actual}" ]
then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
return=1
fi
echo -n "checking a bignum was created: "
@ -125,7 +128,7 @@ then
echo "OK"
else
echo "Fail"
exit 1
return=1
fi
@ -134,7 +137,7 @@ fi
a=1152921504606846977
c=`echo "$a + $a" | bc`
echo -n "adding $a to $a: "
echo -n "$0 => adding $a to $a: "
expected='t'
output=`echo "(= (+ $a $b) $c)" | target/psse -v 2 2>psse.log`
@ -147,7 +150,7 @@ then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
return=1
fi
#####################################################################
@ -155,7 +158,7 @@ fi
a=1152921504606846977
c=`echo "$a * 5" | bc`
echo -n "adding $a, $a $a, $a, $a: "
echo -n "$0 => adding $a, $a $a, $a, $a: "
expected='t'
output=`echo "(= (+ $a $a $a $a $a) $c)" | target/psse -v 2 2>psse.log`
@ -168,7 +171,7 @@ then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
return=1
fi
@ -186,23 +189,23 @@ actual=`echo $output |\
tail -1 |\
sed 's/\,//g'`
echo -n "adding $a to $b: "
echo -n "$0 => adding $a to $b: "
if [ "${expected}" = "${actual}" ]
then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
return=1
fi
echo -n "checking a bignum was created: "
echo -n "$0 => checking a bignum was created: "
grep 'BIGNUM!' psse.log > /dev/null
if [ $? -eq "0" ]
then
echo "OK"
else
echo "Fail"
exit 1
return=1
fi
@ -219,23 +222,23 @@ actual=`echo $output |\
tail -1 |\
sed 's/\,//g'`
echo -n "adding $a to $b: "
echo -n "$0 => adding $a to $b: "
if [ "${expected}" = "${actual}" ]
then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
return=1
fi
echo -n "checking a bignum was created: "
echo -n "$0 => checking a bignum was created: "
grep 'BIGNUM!' psse.log > /dev/null
if [ $? -eq "0" ]
then
echo "OK"
else
echo "Fail"
exit 1
return=1
fi
@ -253,21 +256,23 @@ actual=`echo $output |\
tail -1 |\
sed 's/\,//g'`
echo -n "adding $a to $b: "
echo -n "$0 => adding $a to $b: "
if [ "${expected}" = "${actual}" ]
then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
return=1
fi
echo -n "checking a bignum was created: "
echo -n "$0 => checking a bignum was created: "
grep 'BIGNUM!' psse.log > /dev/null
if [ $? -eq "0" ]
then
echo "OK"
else
echo "Fail"
exit 1
return=1
fi
exit ${return}

View file

@ -1,5 +1,7 @@
#!/bin/bash
return=0
#####################################################################
# last 'smallnum' value:
# sbcl calculates (expt 2 59) => 576460752303423488
@ -18,13 +20,13 @@ EOF`
actual=`echo "$output" | tail -1 | sed 's/\,//g'`
echo -n "(expt 2 59): "
echo -n "$0 => (expt 2 59): "
if [ "${expected}" = "${actual}" ]
then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
return=1
fi
#####################################################################
@ -45,13 +47,13 @@ EOF`
actual=`echo "$output" | tail -1 | sed 's/\,//g'`
echo -n "(expt 2 60): "
echo -n "$0 => (expt 2 60): "
if [ "${expected}" = "${actual}" ]
then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
return=1
fi
#####################################################################
@ -72,13 +74,13 @@ EOF`
actual=`echo "$output" | tail -1 | sed 's/\,//g'`
echo -n "(expt 2 61): "
echo -n "$0 => (expt 2 61): "
if [ "${expected}" = "${actual}" ]
then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
return=1
fi
@ -99,13 +101,13 @@ EOF`
actual=`echo "$output" | tail -1 | sed 's/\,//g'`
echo -n "(expt 2 64): "
echo -n "$0 => (expt 2 64): "
if [ "${expected}" = "${actual}" ]
then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
return=1
fi
# sbcl calculates (expt 2 65) => 36893488147419103232
@ -124,12 +126,13 @@ EOF`
actual=`echo "$output" | tail -1 | sed 's/\,//g'`
echo -n "(expt 2 65): "
echo -n "$0 => (expt 2 65): "
if [ "${expected}" = "${actual}" ]
then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
return=1
fi
exit 0
exit ${return}

View file

@ -1,5 +1,7 @@
#!/bin/bash
return=0
#####################################################################
# large number, not actally a bignum
expected='576460752303423488'
@ -9,13 +11,13 @@ actual=`echo $output |\
sed 's/\,//g' |\
sed 's/[^0-9]*\([0-9]*\).*/\1/'`
echo -n "printing $expected: "
echo -n "$0 => printing $expected: "
if [ "${expected}" = "${actual}" ]
then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
return=1
fi
@ -28,13 +30,13 @@ actual=`echo $output |\
sed 's/\,//g' |\
sed 's/[^0-9]*\([0-9]*\).*/\1/'`
echo -n "printing $expected: "
echo -n "$0 => printing $expected: "
if [ "${expected}" = "${actual}" ]
then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
return=1
fi
@ -47,13 +49,13 @@ actual=`echo $output |\
sed 's/\,//g' |\
sed 's/[^0-9]*\([0-9]*\).*/\1/'`
echo -n "printing $expected: "
echo -n "$0 => printing $expected: "
if [ "${expected}" = "${actual}" ]
then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
return=1
fi
@ -70,13 +72,13 @@ actual=`echo $output |\
sed 's/\,//g' |\
sed 's/[^0-9]*\([0-9]*\).*/\1/'`
echo -n "printing $expected: "
echo -n "$0 => printing $expected: "
if [ "${expected}" = "${actual}" ]
then
echo "OK"
else
echo "Fail: expected '${expected}', \n got '${actual}'"
exit 1
return=1
fi
exit 0
@ -90,13 +92,13 @@ actual=`echo $output |\
sed 's/\,//g' |\
sed 's/[^0-9]*\([0-9]*\).*/\1/'`
echo -n "printing $expected: "
echo -n "$0 => printing $expected: "
if [ "${expected}" = "${actual}" ]
then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
return=1
fi
exit 0
exit ${return}

View file

@ -1,5 +1,7 @@
#!/bin/bash
return=0
#####################################################################
# subtract a smallnum from a smallnum to produce a smallnum
# (right on the boundary)
@ -12,13 +14,13 @@ actual=`echo $output |\
tail -1 |\
sed 's/\,//g'`
echo -n "subtracting $b from $a: "
echo -n "$0 => subtracting $b from $a: "
if [ "${expected}" = "${actual}" ]
then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
return=1
fi
echo -n "checking no bignum was created: "
@ -28,7 +30,7 @@ then
echo "OK"
else
echo "Fail"
exit 1
return=1
fi
#####################################################################
@ -43,13 +45,13 @@ actual=`echo $output |\
tail -1 |\
sed 's/\,//g'`
echo -n "subtracting $b from $a: "
echo -n "$0 => subtracting $b from $a: "
if [ "${expected}" = "${actual}" ]
then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
return=1
fi
#####################################################################
@ -63,13 +65,13 @@ actual=`echo $output |\
tail -1 |\
sed 's/\,//g'`
echo -n "subtracting $b from $a: "
echo -n "$0 => subtracting $b from $a: "
if [ "${expected}" = "${actual}" ]
then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
return=1
fi
@ -85,13 +87,13 @@ actual=`echo $output |\
tail -1 |\
sed 's/\,//g'`
echo -n "subtracting $b from $a: "
echo -n "$0 => subtracting $b from $a: "
if [ "${expected}" = "${actual}" ]
then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
return=1
fi
#####################################################################
@ -105,12 +107,13 @@ actual=`echo $output |\
tail -1 |\
sed 's/\,//g'`
echo -n "subtracting $b from $a: "
echo -n "$0 => subtracting $b from $a: "
if [ "${expected}" = "${actual}" ]
then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
return=1
fi
exit ${return}

View file

@ -1,5 +1,7 @@
#!/bin/bash
return=0
expected='1,152,921,504,606,846,976'
# 1,152,921,504,606,846,975 is the largest single cell positive integer;
# consequently 1,152,921,504,606,846,976 is the first two cell positive integer.
@ -9,6 +11,8 @@ if [ "${expected}" = "${actual}" ]
then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
echo "$0 => Fail: expected '${expected}', got '${actual}'"
return=1
fi
exit ${return}

View file

@ -1,5 +1,7 @@
#!/bin/bash
result=0
expected='5'
actual=`echo "(cond ((equal 2 2) 5))" | target/psse | tail -1`
@ -8,7 +10,7 @@ then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
result=1
fi
expected='"should"'
@ -17,8 +19,9 @@ actual=`echo "(cond ((equal 2 3) \"shouldn't\")(t \"should\"))" | target/psse |
if [ "${expected}" = "${actual}" ]
then
echo "OK"
exit 0
else
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
result=1
fi
exit ${result}

View file

@ -1,5 +1,7 @@
#!/bin/bash
result=0
expected='11'
actual=`echo "(let ((a . 5)(b . 6)) (+ a b))" | target/psse | tail -1`
@ -8,7 +10,7 @@ then
echo "OK"
else
echo "Fail: expected '$expected', got '$actual'"
exit 1
result=1
fi
expected='1'
@ -17,8 +19,9 @@ actual=`echo "(let ((a . 5)(b . 6)) (+ a b) (- b a))" | target/psse | tail -1`
if [ "${expected}" = "${actual}" ]
then
echo "OK"
exit 0
else
echo "Fail: expected '$expected', got '$actual'"
exit 1
result=1
fi
exit ${result}

View file

@ -1,5 +1,7 @@
#!/bin/bash
result=0
expected="(0 1 2 3 4 5 6 7 8 9 a b c d e f)"
actual=`echo "(list 0 1 2 3 4 5 6 7 8 9 'a 'b 'c 'd 'e 'f)" | target/psse | tail -1`
@ -9,7 +11,7 @@ then
echo "OK"
else
echo "Fail: expected '$expected', got '$actual'"
exit 1
result=1
fi
expected="(0 1 2 3 4)"
@ -21,7 +23,7 @@ then
echo "OK"
else
echo "Fail: expected '$expected', got '$actual'"
exit 1
result=1
fi
expected="(0 1 2 3 4 5 6 7)"
@ -34,5 +36,7 @@ then
exit 0
else
echo "Fail: expected '$expected', got '$actual'"
exit 1
result=1
fi
exit ${result}

View file

@ -1,5 +1,7 @@
#!/bin/bash
result=1
expected="120"
actual=`echo "(+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)" | target/psse | tail -1`
@ -8,7 +10,7 @@ then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
result=1
fi
# check that all the args are actually being evaluated...
@ -20,5 +22,7 @@ then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
result=1
fi
return ${result}

View file

@ -1,5 +1,7 @@
#!/bin/bash
result=0
#####################################################################
# Create an empty map using map notation
expected='{}'
@ -11,7 +13,7 @@ then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
result=1
fi
#####################################################################
@ -25,7 +27,7 @@ then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
result=1
fi
#####################################################################
@ -41,7 +43,7 @@ then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
result=1
fi
#####################################################################
@ -57,7 +59,7 @@ then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
result=1
fi
#####################################################################
@ -71,7 +73,7 @@ then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
result=1
fi
@ -86,5 +88,7 @@ then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
result=1
fi
exit ${result}

View file

@ -1,5 +1,7 @@
#!/bin/bash
result=0
expected='6'
actual=`echo "(multiply 2 3)" | target/psse | tail -1`
@ -8,7 +10,7 @@ then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
result=1
fi
expected='7.5'
@ -17,8 +19,9 @@ actual=`echo "(multiply 2.5 3)" | target/psse | tail -1`
if [ "${expected}" = "${actual}" ]
then
echo "OK"
exit 0
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
result=1
fi
exit ${result}

View file

@ -1,5 +1,7 @@
#!/bin/bash
result=0
#####################################################################
# Create a path from root using compact path notation
expected='(-> oblist :users :simon :functions (quote assoc))'
@ -11,7 +13,7 @@ then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
result=1
fi
#####################################################################
@ -25,7 +27,8 @@ then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
result=1
fi
exit ${result}

View file

@ -1,5 +1,7 @@
#!/bin/bash
result=0
expected='5'
actual=`echo "(progn (add 2 3))" | target/psse | tail -1`
@ -8,7 +10,7 @@ then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
result=1
fi
expected='"foo"'
@ -17,8 +19,9 @@ actual=`echo "(progn (add 2.5 3) \"foo\")" | target/psse | tail -1`
if [ "${expected}" = "${actual}" ]
then
echo "OK"
exit 0
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
result=1
fi
exit ${result}

View file

@ -1,5 +1,7 @@
#!/bin/bash
result=0
expected='"god yzal eht revo depmuj xof nworb kciuq ehT"'
actual=`echo '(reverse "The quick brown fox jumped over the lazy dog")' | target/psse | tail -1`
@ -8,7 +10,7 @@ then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
result=1
fi
expected='(1,024 512 256 128 64 32 16 8 4 2)'
@ -19,7 +21,7 @@ then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
result=1
fi
expected='esrever'
@ -31,6 +33,8 @@ then
exit 0
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
result=1
fi
echo ${result}

View file

@ -11,6 +11,6 @@ then
rm ${tmp}
exit 0
else
echo "Fail: expected '$expected', got '$actual'"
echo "$0 => Fail: expected '$expected', got '$actual'"
exit 1
fi

View file

@ -10,6 +10,6 @@ then
echo "OK"
exit 0
else
echo "Fail: expected '${expected}', got '${actual}'"
echo "$0 => Fail: expected '${expected}', got '${actual}'"
exit 1
fi

View file

@ -1,5 +1,7 @@
#!/bin/bash
result=0
# We should be able to cons a single character string onto the front of a string
expected='"Test"'
actual=`echo '(cons "T" "est")' | target/psse | tail -1`
@ -9,7 +11,7 @@ then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
result=1
fi
# But if the first argument has more than one character, we should get a dotted pair
@ -21,5 +23,8 @@ then
echo "OK"
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
result=1
fi
exit ${result}