summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--com.c2
-rwxr-xr-xrun_tests.sh42
3 files changed, 30 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index df852dd..2a50d33 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ bth: $(CS) $(HS) Makefile
$(CC) $(CFLAGS) -o bth $(CS)
test: bth
- ./run_tests.sh
+ ./run_tests.sh '*clos*'
clean:
rm bth
diff --git a/com.c b/com.c
index 432ebb4..ca18c36 100644
--- a/com.c
+++ b/com.c
@@ -655,6 +655,8 @@ static void cpl_expr(Compiler *C, Val v, int flags) {
// so (returned values) = (stack change) - (new locals) = 1
CHECK( (stack_cur_b - stack_cur_a) - (nlocals_b - nlocals_a) == 1,
"stack corruption (compiler bug)");
+ CHECK( (flags & F_toplevel) || (nlocals_b == nlocals_a),
+ "local declared not at top level (compiler bug)");
}
diff --git a/run_tests.sh b/run_tests.sh
index 16201b5..e852582 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -4,27 +4,39 @@ pass=0
fail=0
skip=0
+skipglob="$1"
+
+
+skip() {
+ printf '\033[33mSKIP\033[0m %s (%s)\n' "$testname" "$1"
+ skip=$((skip + 1))
+}
+
for testfile in tests/*.bth; do
outfile=${testfile%.bth}.out
testname=${testfile#tests/}
testname=${testname%.bth}
if [ ! -f "$outfile" ]; then
- printf '\033[33mSKIP\033[0m %s (no output file)\n' "$testname"
- skip=$((skip + 1))
- else
- output="$(./bth "$testfile" 2>&1)"
- echo "$output" | diff "$outfile" - >/dev/null
- diff_res=$?
- case $diff_res in
- 0) printf '\033[32m\033[1mPASS\033[0m %s\n' "$testname"
- pass=$((pass + 1)) ;;
- 1) printf '\033[31m\033[1mFAIL\033[0m %s\n' "$testname"
- printf "\tgot output: %s\n" "$(echo "$output" | head -n4)"
- printf "\texpected: "
- cat "$outfile"
- fail=$((fail + 1)) ;;
- esac
+ skip "no output file"
+ continue
fi
+ case "$testname" in
+ $skipglob) skip "matches skip glob $skipglob"
+ continue ;;
+ esac
+
+ output="$(./bth "$testfile" 2>&1)"
+ echo "$output" | diff "$outfile" - >/dev/null
+ diff_res=$?
+ case $diff_res in
+ 0) printf '\033[32m\033[1mPASS\033[0m %s\n' "$testname"
+ pass=$((pass + 1)) ;;
+ 1) printf '\033[31m\033[1mFAIL\033[0m %s\n' "$testname"
+ printf "\tgot output: %s\n" "$(echo "$output" | head -n4)"
+ printf "\texpected: "
+ cat "$outfile"
+ fail=$((fail + 1)) ;;
+ esac
done
echo