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,18 +135,20 @@ 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" "\
(if (< a 2) \ (def fib (fn (a) \
a \ (if (< a 2) \
(+ (fib (- a 1)) (fib (- a 2))) \ a \
)));\ (+ (fib (- a 1)) (fib (- a 2))) \
(fib 20)" "6765" )));\
check "Factorial" "(def fac (fn (a) \ (fib 20)" "6765"
(if (= a 1) \ check "Factorial" "\
1 \ (def fac (fn (a) \
(* a (fac (- a 1)) ) \ (if (= a 1) \
)));\ 1 \
(fac 11)" "39916800" (* a (fac (- a 1)) ) \
)));\
(fac 11)" "39916800"
check "LambdaClone" "(def y (fn (a) (* 10 a))) (def b y) (def y 12345) ((b 5) y)" "( 50 12345 )" check "LambdaClone" "(def y (fn (a) (* 10 a))) (def b y) (def y 12345) ((b 5) y)" "( 50 12345 )"
check "Duplicate" "(def dupe (fn (a) (() (a a a))));(dupe (*10 10))" "( 100 100 100 )" check "Duplicate" "(def dupe (fn (a) (() (a a a))));(dupe (*10 10))" "( 100 100 100 )"
endBlock endBlock