From c9babe439d2e254cbbb049e37c83d3f26ba13a9a Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Mon, 5 Jul 2021 00:18:14 -0400 Subject: [PATCH] Test display and code style tweaks --- src/Makefile | 2 +- src/tests.sh | 33 +++++++++++++++++++-------------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/Makefile b/src/Makefile index 518d5c5..221e4e6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -8,7 +8,7 @@ SCRIPTDIR ?= /usr/local/share/pebblisp GCC_COM ?= gcc -g -O0 -Wall -o $(exe) -D STANDALONE -DSCRIPTDIR=\"$(SCRIPTDIR)\" all: - $(GCC_COM) $(files) && ./tests.sh + $(GCC_COM) $(files) && echo; ./tests.sh notest: $(GCC_COM) $(files) diff --git a/src/tests.sh b/src/tests.sh index 1f194d0..24aa3ba 100755 --- a/src/tests.sh +++ b/src/tests.sh @@ -40,7 +40,6 @@ fail() { } check() { - local output if $VALGRIND; then local output=$($VALCOM ./pl "(loadfile \"examples/lib.pbl\") $2") else @@ -56,7 +55,6 @@ check() { } echo "STARTING TESTS" -echo "" title "Plain returns" check "PlainRet" "10" "10" @@ -84,11 +82,16 @@ check "LessThan" "(< 23847123 19375933)" "F" check "Equality" "(= 987654321 987654321 )" "T" check "StringEquality" "(= \"Bean\" \"Bean\" )" "T" check "StringInequality" "(= \"Beans\" \"Bean\" )" "F" +check "NullInequality" "(= \"Beans\" \"\" )" "F" endBlock title "TypeCheck" check "IsNum" "(isnum 23847123)" "T" 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 title "Ifs/Bools" @@ -132,18 +135,20 @@ endBlock title "Lambdas" 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" -check "Factorial" "(def fac (fn (a) \ - (if (= a 1) \ - 1 \ - (* a (fac (- a 1)) ) \ - )));\ - (fac 11)" "39916800" +check "FbnciSeq" "\ + (def fib (fn (a) \ + (if (< a 2) \ + a \ + (+ (fib (- a 1)) (fib (- a 2))) \ + )));\ + (fib 20)" "6765" +check "Factorial" "\ + (def fac (fn (a) \ + (if (= a 1) \ + 1 \ + (* 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 "Duplicate" "(def dupe (fn (a) (() (a a a))));(dupe (*10 10))" "( 100 100 100 )" endBlock