Begin simple testing script
This commit is contained in:
parent
96abccec7e
commit
9fe35450df
|
@ -0,0 +1,45 @@
|
|||
#!/bin/bash
|
||||
PASSES=0
|
||||
FAILS=0
|
||||
|
||||
pass() {
|
||||
echo "$1 test PASSED"
|
||||
((PASSES++))
|
||||
}
|
||||
|
||||
fail() {
|
||||
echo "$1 test FAILED"
|
||||
((FAILS++))
|
||||
}
|
||||
|
||||
check() {
|
||||
local output=$(./pebblisp "$2")
|
||||
if [ "$output" == "$3" ]; then
|
||||
pass $1
|
||||
else
|
||||
fail $1
|
||||
fi
|
||||
}
|
||||
|
||||
check "Addition" "(+ 1093 102852)" "103945"
|
||||
check "Multiply" "(* 1000 10000)" "10000000"
|
||||
check "Division" "(/ 6418425 65)" "98745"
|
||||
echo ""
|
||||
check "ChainAdd" "(+ 3917 17304 1293844 400 100000)" "1415465"
|
||||
check "ChainMul" "(* 8263 23 123)" "23376027"
|
||||
check "ChainDiv" "(/ 1493856 741 96 7)" "3"
|
||||
echo ""
|
||||
check "GratrThn" "(> 23847123 19375933)" "T"
|
||||
check "LessThan" "(< 23847123 19375933)" "F"
|
||||
check "Equality" "(= 987654321 987654321 )" "T"
|
||||
echo ""
|
||||
check "IfReturn" "(if (T) 123456789 987654321)" "123456789"
|
||||
check "IfRetTwo" "(if F 123456789 987654321)" "987654321"
|
||||
check "IfRetTwo" "(if () 123456789 987654321)" "987654321"
|
||||
# check "IfRetTwo" "(if (()) 123456789 987654321)" "123456789"
|
||||
echo ""
|
||||
check "RegLists" "(1 2 3 4 5)" "( 1 2 3 4 5 )"
|
||||
|
||||
echo ""
|
||||
echo "$PASSES Tests Passed"
|
||||
echo "$FAILS Tests Failed"
|
Loading…
Reference in New Issue