diff --git a/tests/lua/sexpr2.lua b/tests/lua/sexpr2.lua index a770e265b..92865a100 100644 --- a/tests/lua/sexpr2.lua +++ b/tests/lua/sexpr2.lua @@ -1,14 +1,3 @@ -function check_error(f) - ok, msg = pcall(function () - f() - end) - if ok then - error("unexpected success...") - else - print("caught expected error: ", msg) - end -end - s = sexpr(1, 2, 3) print(s) s = sexpr(1, 2, 3, nil) diff --git a/tests/lua/test.sh b/tests/lua/test.sh new file mode 100755 index 000000000..97f4540c4 --- /dev/null +++ b/tests/lua/test.sh @@ -0,0 +1,24 @@ +#!/bin/bash +if [ $# -ne 1 ]; then + echo "Usage: test.sh [leanlua-executable-path]" + exit 1 +fi +ulimit -s unlimited +LEANLUA=$1 +NUM_ERRORS=0 +for f in `ls *.lua`; do + echo "-- testing $f" + if $LEANLUA util.lua $f > $f.produced.out; then + echo "-- worked" + else + echo "ERROR executing $f, produced output is at $f.produced.out" + NUM_ERRORS=$(($NUM_ERRORS+1)) + fi +done +if [ $NUM_ERRORS -gt 0 ]; then + echo "-- Number of errors: $NUM_ERRORS" + exit 1 +else + echo "-- Passed" + exit 0 +fi diff --git a/tests/lua/util.lua b/tests/lua/util.lua new file mode 100644 index 000000000..ccd3ccac8 --- /dev/null +++ b/tests/lua/util.lua @@ -0,0 +1,11 @@ +-- Execute f, and make sure is throws an error +function check_error(f) + ok, msg = pcall(function () + f() + end) + if ok then + error("unexpected success...") + else + print("caught expected error: ", msg) + end +end