Added valgrind op to tests. Added recursive test.
This commit is contained in:
parent
8a45444c52
commit
45cbf51f50
|
@ -1,6 +1,9 @@
|
|||
all:
|
||||
gcc -g -O0 -o pebblisp -D STANDALONE pebblisp.c tokens.c object.c env.c && ./tests.sh
|
||||
|
||||
val:
|
||||
gcc -g -O0 -o pebblisp -D STANDALONE pebblisp.c tokens.c object.c env.c && ./tests.sh -val
|
||||
|
||||
debug:
|
||||
gcc -g -O0 -o pebblisp -D STANDALONE -D DEBUG pebblisp.c tokens.c object.c env.c && ./tests.sh
|
||||
|
||||
|
|
23
src/tests.sh
23
src/tests.sh
|
@ -1,6 +1,11 @@
|
|||
#!/bin/bash
|
||||
PASSES=0
|
||||
FAILS=0
|
||||
VALGRIND=0
|
||||
|
||||
if [ "$1" == "-val" ]; then
|
||||
VALGRIND=1
|
||||
fi
|
||||
|
||||
pass() {
|
||||
echo "[0;32m$1 test PASSED[0m"
|
||||
|
@ -13,7 +18,13 @@ fail() {
|
|||
}
|
||||
|
||||
check() {
|
||||
local output=$(./pebblisp "$2")
|
||||
local output
|
||||
if (($VALGRIND == 1)); then
|
||||
local output=$(valgrind --leak-check=full ./pebblisp "$2")
|
||||
else
|
||||
local output=$(./pebblisp "$2")
|
||||
fi
|
||||
|
||||
if [ "$output" == "$3" ]; then
|
||||
pass $1
|
||||
else
|
||||
|
@ -22,7 +33,8 @@ check() {
|
|||
fi
|
||||
}
|
||||
|
||||
check "PlainRet" "5" "5"
|
||||
check "PlainRet" "10" "10"
|
||||
check "StrRetrn" "\"hey\"" "hey"
|
||||
echo ""
|
||||
check "Addition" "(+ 1093 102852)" "103945"
|
||||
check "Multiply" "(*1000 10000)" "10000000"
|
||||
|
@ -57,7 +69,12 @@ check "DemoFunc" "(spent 68)" "Tip: \$13.60"
|
|||
echo ""
|
||||
check "MultStmt" "(def yee (fn (a) (* 10 a))) (yee 5)" "50"
|
||||
check "DefinMap" "(def yee (fn (a) (* 10 a))) (map yee (5 10 2 (+ 12 0)))" "( 50 100 20 120 )"
|
||||
|
||||
check "FbnciSeq" "(def fib (fn (a) \
|
||||
(if (< a 2) \
|
||||
a \
|
||||
(+ (fib (- a 1)) (fib (- a 2))) \
|
||||
))) \
|
||||
(fib 20)" "6765"
|
||||
echo ""
|
||||
|
||||
if [ "$FAILS" -ne "0" ]; then
|
||||
|
|
Loading…
Reference in New Issue