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

@ -102,7 +102,7 @@ void print_map( URL_FILE * output, struct cons_pointer map ) {
print( output, hashmap_get( map, key ) ); print( output, hashmap_get( map, key ) );
if ( !nilp( c_cdr( ks ) ) ) { if ( !nilp( c_cdr( ks ) ) ) {
url_fputws( L" ", output ); url_fputws( L", ", output );
} }
} }

View file

@ -196,7 +196,7 @@ struct cons_pointer hashmap_put_all( struct cons_pointer mapp,
assoc = c_cdr( assoc); assoc = c_cdr( assoc);
} }
} else if (hashmapp( assoc)) { } else if (hashmapp( assoc)) {
for (struct cons_pointer keys = hashmap_keys( mapp); !nilp( keys); for (struct cons_pointer keys = hashmap_keys( assoc); !nilp( keys);
keys = c_cdr( keys)) { keys = c_cdr( keys)) {
struct cons_pointer key = c_car( keys); struct cons_pointer key = c_car( keys);
hashmap_put( mapp, key, hashmap_get( assoc, key)); hashmap_put( mapp, key, hashmap_get( assoc, key));

View file

@ -1,5 +1,58 @@
# State of Play # State of Play
## 20260203
I'm consciously avoiding the bignum issue for now. My current thinking is that if the C code only handles 64 bit integers, and bignums have to be done in Lisp code, that's perfectly fine with me.
### Hashmaps, assoc lists, and generalised key/value stores
I now have the oblist working as a hashmap, and also hybrid assoc lists which incorporate hashmaps working. I don't 100% have consistent methods for reading stores which may be plain old assoc lists, new hybrid assoc lists, or hashmaps working but it isn't far off. This also takes me streets further towards doing hierarchies of hashmaps, allowing my namespace idea to work — and hybrid assoc lists provide a very sound basis for building environment structures.
Currently all hashmaps are mutable, and my doctrine is that that is fixable when access control lists are actually implemented.
#### assoc
The function `(assoc store key) => value` should be the standard way of getting a value out of a store.
#### put!
The function `(put! store key value) => store` should become the standard way of setting a value in a store (of course, if the store is an assoc list or an immutable map, a new store will be returned which holds the additional key/value binding).
### State of unit tests
Currently:
> Tested 45, passed 39, failed 6
But the failures are as follows:
```
unit-tests/bignum-add.sh => checking a bignum was created: Fail
unit-tests/bignum-add.sh => adding 1152921504606846977 to 1: Fail: expected 't', got 'nil'
unit-tests/bignum-add.sh => adding 1 to 1152921504606846977: Fail: expected 't', got 'nil'
unit-tests/bignum-add.sh => adding 1152921504606846977 to 1152921504606846977: Fail: expected 't', got 'nil'
unit-tests/bignum-add.sh => adding 10000000000000000000 to 10000000000000000000: Fail: expected 't', got 'nil'
unit-tests/bignum-add.sh => adding 1 to 1329227995784915872903807060280344576: Fail: expected 't', got 'nil'
unit-tests/bignum-add.sh => adding 1 to 3064991081731777716716694054300618367237478244367204352: Fail: expected 't', got 'nil'
unit-tests/bignum-expt.sh => (expt 2 60): Fail: expected '1152921504606846976', got '1'
unit-tests/bignum-expt.sh => (expt 2 61): Fail: expected '2305843009213693952', got '2'
unit-tests/bignum-expt.sh => (expt 2 64): Fail: expected '18446744073709551616', got '16'
unit-tests/bignum-expt.sh => (expt 2 65): Fail: expected '36893488147419103232', got '32'
unit-tests/bignum-print.sh => printing 1152921504606846976: Fail: expected '1152921504606846976', got '1'
unit-tests/bignum-print.sh => printing 1152921504606846977: Fail: expected '1152921504606846977', got '2'
unit-tests/bignum-print.sh => printing 1329227995784915872903807060280344576: Fail: expected '1329227995784915872903807060280344576', \n got '1151321504605245376'
unit-tests/bignum.sh => unit-tests/bignum.sh => Fail: expected '1,152,921,504,606,846,976', got '1'
unit-tests/bignum-subtract.sh => unit-tests/bignum-subtract.sh => subtracting 1 from 1152921504606846976: Fail: expected '1152921504606846975', got '0'
unit-tests/bignum-subtract.sh => subtracting 1 from 1152921504606846977: Fail: expected '1152921504606846976', got '1'
unit-tests/bignum-subtract.sh => subtracting 1 from 1152921504606846978: Fail: expected '1152921504606846977', got '2'
unit-tests/bignum-subtract.sh => subtracting 1152921504606846977 from 1: Fail: expected '-1152921504606846976', got '1'
unit-tests/bignum-subtract.sh => subtracting 10000000000000000000 from 20000000000000000000: Fail: expected '10000000000000000000', got '-376293541461622793'
unit-tests/memory.sh
```
In other words, all failures are in bignum arithmetic **except** that I still have a major memory leak due to not decrefing somewhere where I ought to.
### Zig
## 20250704 ## 20250704
Right, I'm getting second and subsequent integer cells with negative values, which should not happen. This is probably the cause of (at least some of) the bignum problems. I need to find out why. This is (probably) fixable. Right, I'm getting second and subsequent integer cells with negative values, which should not happen. This is probably the cause of (at least some of) the bignum problems. I need to find out why. This is (probably) fixable.

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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