Test display and code style tweaks

This commit is contained in:
Sage Vaillancourt 2021-07-05 00:18:14 -04:00
parent 2af48f63ca
commit c9babe439d
2 changed files with 20 additions and 15 deletions

View File

@ -8,7 +8,7 @@ SCRIPTDIR ?= /usr/local/share/pebblisp
GCC_COM ?= gcc -g -O0 -Wall -o $(exe) -D STANDALONE -DSCRIPTDIR=\"$(SCRIPTDIR)\" GCC_COM ?= gcc -g -O0 -Wall -o $(exe) -D STANDALONE -DSCRIPTDIR=\"$(SCRIPTDIR)\"
all: all:
$(GCC_COM) $(files) && ./tests.sh $(GCC_COM) $(files) && echo; ./tests.sh
notest: notest:
$(GCC_COM) $(files) $(GCC_COM) $(files)

View File

@ -40,7 +40,6 @@ fail() {
} }
check() { check() {
local output
if $VALGRIND; then if $VALGRIND; then
local output=$($VALCOM ./pl "(loadfile \"examples/lib.pbl\") $2") local output=$($VALCOM ./pl "(loadfile \"examples/lib.pbl\") $2")
else else
@ -56,7 +55,6 @@ check() {
} }
echo "STARTING TESTS" echo "STARTING TESTS"
echo ""
title "Plain returns" title "Plain returns"
check "PlainRet" "10" "10" check "PlainRet" "10" "10"
@ -84,11 +82,16 @@ check "LessThan" "(< 23847123 19375933)" "F"
check "Equality" "(= 987654321 987654321 )" "T" check "Equality" "(= 987654321 987654321 )" "T"
check "StringEquality" "(= \"Bean\" \"Bean\" )" "T" check "StringEquality" "(= \"Bean\" \"Bean\" )" "T"
check "StringInequality" "(= \"Beans\" \"Bean\" )" "F" check "StringInequality" "(= \"Beans\" \"Bean\" )" "F"
check "NullInequality" "(= \"Beans\" \"\" )" "F"
endBlock endBlock
title "TypeCheck" title "TypeCheck"
check "IsNum" "(isnum 23847123)" "T" check "IsNum" "(isnum 23847123)" "T"
check "IsntNum" "(isnum \"WORDS\")" "F" check "IsntNum" "(isnum \"WORDS\")" "F"
check "IsString" "(isstr 'words')" "T"
check "IsStringEmpty" "(isstr '')" "T"
check "NumNotString" "(isstr 5)" "F"
check "ListNotString" "(isstr ('hello'))" "F"
endBlock endBlock
title "Ifs/Bools" title "Ifs/Bools"
@ -132,13 +135,15 @@ endBlock
title "Lambdas" title "Lambdas"
check "MultStmt" "(def yee (fn (a) (* 10 a))) ; (yee 5)" "50" 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 "DefinMap" "(def yee (fn (a) (* 10 a))) ; (map yee (5 10 2 (+ 12 0)))" "( 50 100 20 120 )"
check "FbnciSeq" "(def fib (fn (a) \ check "FbnciSeq" "\
(def fib (fn (a) \
(if (< a 2) \ (if (< a 2) \
a \ a \
(+ (fib (- a 1)) (fib (- a 2))) \ (+ (fib (- a 1)) (fib (- a 2))) \
)));\ )));\
(fib 20)" "6765" (fib 20)" "6765"
check "Factorial" "(def fac (fn (a) \ check "Factorial" "\
(def fac (fn (a) \
(if (= a 1) \ (if (= a 1) \
1 \ 1 \
(* a (fac (- a 1)) ) \ (* a (fac (- a 1)) ) \