post-scarcity/unit-tests/recursion.sh
Simon Brooke 02fe5669d8 Complete reworking of the REPL
which is good in itself, but not what I was meant to be working on.
2018-12-30 17:56:15 +00:00

23 lines
362 B
Bash

#!/bin/bash
expected='nil 3628800'
output=`target/psse 2>/dev/null <<EOF
(progn
(set! fact
(lambda (n)
(cond ((= n 1) 1)
(t (* n (fact (- n 1)))))))
nil)
(fact 10)
EOF`
actual=`echo $output | tail -1`
if [ "${expected}" = "${actual}" ]
then
echo "OK"
exit 0
else
echo "Fail: expected '${expected}', got '${actual}'"
exit 1
fi