From 8151ce5ffec4283a3bc1eeea52b8f9b17cb5d069 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 29 May 2023 10:54:33 -0400 Subject: tests: add initial tests and test runner script --- tests/add.forth | 4 ++++ tests/define-countdown.forth | 9 +++++++++ tests/define-mult.forth | 6 ++++++ tests/simple-if.forth | 5 +++++ tests/simple-if2.forth | 4 ++++ 5 files changed, 28 insertions(+) create mode 100644 tests/add.forth create mode 100644 tests/define-countdown.forth create mode 100644 tests/define-mult.forth create mode 100644 tests/simple-if.forth create mode 100644 tests/simple-if2.forth (limited to 'tests') diff --git a/tests/add.forth b/tests/add.forth new file mode 100644 index 0000000..690bdba --- /dev/null +++ b/tests/add.forth @@ -0,0 +1,4 @@ +INPUT +1 3 + . +OUTPUT +4 diff --git a/tests/define-countdown.forth b/tests/define-countdown.forth new file mode 100644 index 0000000..539b229 --- /dev/null +++ b/tests/define-countdown.forth @@ -0,0 +1,9 @@ +INPUT +: countdown dup 0 = not if peek 1 - countdown then ; +5 countdown +OUTPUT +5 +4 +3 +2 +1 diff --git a/tests/define-mult.forth b/tests/define-mult.forth new file mode 100644 index 0000000..5b6f798 --- /dev/null +++ b/tests/define-mult.forth @@ -0,0 +1,6 @@ +INPUT +: multrec over if rot swap over + rot 1 - swap multrec then ; +: mult 0 multrec ; +6 8 mult . +OUTPUT +48 diff --git a/tests/simple-if.forth b/tests/simple-if.forth new file mode 100644 index 0000000..668ea0d --- /dev/null +++ b/tests/simple-if.forth @@ -0,0 +1,5 @@ +INPUT +1 1 = if 5 . then 8 . +OUTPUT +5 +8 diff --git a/tests/simple-if2.forth b/tests/simple-if2.forth new file mode 100644 index 0000000..92bbc6b --- /dev/null +++ b/tests/simple-if2.forth @@ -0,0 +1,4 @@ +INPUT +0 if 5 . then 8 . +OUTPUT +8 -- cgit v1.2.3