simple tests

This commit is contained in:
2024-01-03 19:06:13 +01:00
parent ff45c72b7a
commit 7c54d16273
5 changed files with 49 additions and 2 deletions

12
clitests/fib.psil Normal file
View File

@@ -0,0 +1,12 @@
(define (fib n)
(if (> n 0)
(if (> n 1)
(+ (fib (- n 1))
(fib (- n 2)))
1)
0)
)
(fib 10)
(fib 11)
(fib 12)

3
clitests/fib.psil.ex Normal file
View File

@@ -0,0 +1,3 @@
55
89
144

31
clitests/testall.sh Executable file
View File

@@ -0,0 +1,31 @@
#! /bin/bash
cd "$(dirname "$0")"
FAILED=()
PSIL="../cmake-build-debug/src/psil"
for FILE in *.psil; do
echo "TESTING $FILE"
$PSIL -f $FILE --repl- > $FILE.res
if [ $? -ne 0 ]; then
FAILED+=("test-"$FILE)
continue
fi
diff -w $FILE.res $FILE.ex
if [ $? -ne 0 ]; then
FAILED+=("test-"$FILE)
continue
fi
rm $FILE.res
done
if [ ${#FAILED[@]} -eq 0 ]; then
echo "ALL TESTS PASSED"
else
echo "FAILED: ${FAILED[@]}"
exit -1
fi