From e489d02069d5e34484193a8e2edcdb563c07911a Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Tue, 3 Feb 2026 21:47:25 +0000 Subject: [PATCH] Mainly unit tests. 39/45 currently pass; the failures are all in bignum arithmetic and in deallocation. --- src/io/print.c | 2 +- src/ops/intern.c | 2 +- state-of-play.md | 53 ++++++++++++++++ unit-tests/bignum-add.sh | 65 +++++++++++--------- unit-tests/bignum-expt.sh | 25 ++++---- unit-tests/bignum-print.sh | 24 ++++---- unit-tests/bignum-subtract.sh | 25 ++++---- unit-tests/bignum.sh | 8 ++- unit-tests/cond.sh | 11 ++-- unit-tests/{intepreter.sh => interpreter.sh} | 0 unit-tests/let.sh | 9 ++- unit-tests/list-test,sh | 10 ++- unit-tests/many-args.sh | 8 ++- unit-tests/map.sh | 16 +++-- unit-tests/multiply.sh | 9 ++- unit-tests/path-notation.sh | 7 ++- unit-tests/progn.sh | 9 ++- unit-tests/reverse.sh | 10 ++- unit-tests/slurp.sh | 2 +- unit-tests/string-allocation.sh | 2 +- unit-tests/string-cons.sh | 9 ++- 21 files changed, 206 insertions(+), 100 deletions(-) rename unit-tests/{intepreter.sh => interpreter.sh} (100%) diff --git a/src/io/print.c b/src/io/print.c index 5061b10..8f4b88e 100644 --- a/src/io/print.c +++ b/src/io/print.c @@ -102,7 +102,7 @@ void print_map( URL_FILE * output, struct cons_pointer map ) { print( output, hashmap_get( map, key ) ); if ( !nilp( c_cdr( ks ) ) ) { - url_fputws( L" ", output ); + url_fputws( L", ", output ); } } diff --git a/src/ops/intern.c b/src/ops/intern.c index e908d56..1f6585b 100644 --- a/src/ops/intern.c +++ b/src/ops/intern.c @@ -196,7 +196,7 @@ struct cons_pointer hashmap_put_all( struct cons_pointer mapp, assoc = c_cdr( 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)) { struct cons_pointer key = c_car( keys); hashmap_put( mapp, key, hashmap_get( assoc, key)); diff --git a/state-of-play.md b/state-of-play.md index 498bf60..0855715 100644 --- a/state-of-play.md +++ b/state-of-play.md @@ -1,5 +1,58 @@ # 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 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. diff --git a/unit-tests/bignum-add.sh b/unit-tests/bignum-add.sh index 778015a..293e1e5 100755 --- a/unit-tests/bignum-add.sh +++ b/unit-tests/bignum-add.sh @@ -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} \ No newline at end of file diff --git a/unit-tests/bignum-expt.sh b/unit-tests/bignum-expt.sh index ab9cb24..878acd3 100755 --- a/unit-tests/bignum-expt.sh +++ b/unit-tests/bignum-expt.sh @@ -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} \ No newline at end of file diff --git a/unit-tests/bignum-print.sh b/unit-tests/bignum-print.sh index d556e71..2be8032 100755 --- a/unit-tests/bignum-print.sh +++ b/unit-tests/bignum-print.sh @@ -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} diff --git a/unit-tests/bignum-subtract.sh b/unit-tests/bignum-subtract.sh index 9342913..19c673f 100755 --- a/unit-tests/bignum-subtract.sh +++ b/unit-tests/bignum-subtract.sh @@ -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} \ No newline at end of file diff --git a/unit-tests/bignum.sh b/unit-tests/bignum.sh index aa29143..cec5453 100755 --- a/unit-tests/bignum.sh +++ b/unit-tests/bignum.sh @@ -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} \ No newline at end of file diff --git a/unit-tests/cond.sh b/unit-tests/cond.sh index ab2e2f0..69952c9 100755 --- a/unit-tests/cond.sh +++ b/unit-tests/cond.sh @@ -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} \ No newline at end of file diff --git a/unit-tests/intepreter.sh b/unit-tests/interpreter.sh similarity index 100% rename from unit-tests/intepreter.sh rename to unit-tests/interpreter.sh diff --git a/unit-tests/let.sh b/unit-tests/let.sh index 6454b1e..a4ab77f 100755 --- a/unit-tests/let.sh +++ b/unit-tests/let.sh @@ -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} \ No newline at end of file diff --git a/unit-tests/list-test,sh b/unit-tests/list-test,sh index 32f4797..12fdd60 100644 --- a/unit-tests/list-test,sh +++ b/unit-tests/list-test,sh @@ -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} \ No newline at end of file diff --git a/unit-tests/many-args.sh b/unit-tests/many-args.sh index 0317f77..449f7d8 100755 --- a/unit-tests/many-args.sh +++ b/unit-tests/many-args.sh @@ -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} diff --git a/unit-tests/map.sh b/unit-tests/map.sh index 65dc182..90857ef 100755 --- a/unit-tests/map.sh +++ b/unit-tests/map.sh @@ -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} \ No newline at end of file diff --git a/unit-tests/multiply.sh b/unit-tests/multiply.sh index 94b19f6..aeac7e8 100755 --- a/unit-tests/multiply.sh +++ b/unit-tests/multiply.sh @@ -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} \ No newline at end of file diff --git a/unit-tests/path-notation.sh b/unit-tests/path-notation.sh index a6cb669..70610b0 100755 --- a/unit-tests/path-notation.sh +++ b/unit-tests/path-notation.sh @@ -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} diff --git a/unit-tests/progn.sh b/unit-tests/progn.sh index 352c87a..b9b44eb 100755 --- a/unit-tests/progn.sh +++ b/unit-tests/progn.sh @@ -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} diff --git a/unit-tests/reverse.sh b/unit-tests/reverse.sh index 4c2f0ae..bbc3216 100755 --- a/unit-tests/reverse.sh +++ b/unit-tests/reverse.sh @@ -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} + diff --git a/unit-tests/slurp.sh b/unit-tests/slurp.sh index 0a9bc7c..700df15 100755 --- a/unit-tests/slurp.sh +++ b/unit-tests/slurp.sh @@ -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 diff --git a/unit-tests/string-allocation.sh b/unit-tests/string-allocation.sh index 6f55143..1790788 100755 --- a/unit-tests/string-allocation.sh +++ b/unit-tests/string-allocation.sh @@ -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 diff --git a/unit-tests/string-cons.sh b/unit-tests/string-cons.sh index 0ea0a71..ad6e3d2 100755 --- a/unit-tests/string-cons.sh +++ b/unit-tests/string-cons.sh @@ -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} +