From 2455c38a09be3708062fef3e90bc006ab44dfacb Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 29 May 2023 11:05:20 -0400 Subject: tests: add failing nested if test, make runtests.sh return exit code 1 on failure --- runtests.sh | 3 ++- tests/nested-ifs.forth | 7 +++++++ tests/nested-ifs2.forth | 8 ++++++++ tests/nested-ifs3.forth | 5 +++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tests/nested-ifs.forth create mode 100644 tests/nested-ifs2.forth create mode 100644 tests/nested-ifs3.forth diff --git a/runtests.sh b/runtests.sh index ddff74f..ae77797 100755 --- a/runtests.sh +++ b/runtests.sh @@ -19,7 +19,7 @@ runtest () { if [ "1" -eq "$?" ] ; then echo "Test $n failed: $file" >&2 - echo "Diff:" >&2 + echo "Diff: (expected vs actual)" >&2 echo "$diff" exitcode=1 failed="$(expr "$failed" + 1)" @@ -37,4 +37,5 @@ if [ "0" -eq "$failed" ]; then exit 0 else echo "$failed/$n tests failed" >&2 + exit 1 fi diff --git a/tests/nested-ifs.forth b/tests/nested-ifs.forth new file mode 100644 index 0000000..3b0b39c --- /dev/null +++ b/tests/nested-ifs.forth @@ -0,0 +1,7 @@ +INPUT +: f if 99 . if 88 . then 77 . then 66 . ; +0 1 f +OUTPUT +99 +77 +66 diff --git a/tests/nested-ifs2.forth b/tests/nested-ifs2.forth new file mode 100644 index 0000000..9fe1260 --- /dev/null +++ b/tests/nested-ifs2.forth @@ -0,0 +1,8 @@ +INPUT +: f if 99 . if 88 . then 77 . then 66 . ; +1 1 f +OUTPUT +99 +88 +77 +66 diff --git a/tests/nested-ifs3.forth b/tests/nested-ifs3.forth new file mode 100644 index 0000000..729229d --- /dev/null +++ b/tests/nested-ifs3.forth @@ -0,0 +1,5 @@ +INPUT +: f if 99 . if 88 . then 77 . then 66 . ; +0 0 f +OUTPUT +66 -- cgit v1.2.3