From 991e694b558691264f82d80a7aa1b86ef3d2c92c Mon Sep 17 00:00:00 2001 From: ubq323 Date: Thu, 27 Jun 2024 12:01:33 +0100 Subject: more tests --- tests/flet.bth | 7 +++++++ tests/flet.out | 2 ++ tests/iflet.bth | 8 ++++++++ tests/iflet.out | 1 + tests/letstar.bth | 4 ++++ tests/sumrec.bth | 7 +++++++ tests/sumrec.out | 2 ++ tests/whilelet.bth | 11 +++++++++++ tests/whilelet.out | 2 ++ 9 files changed, 44 insertions(+) create mode 100644 tests/flet.bth create mode 100644 tests/flet.out create mode 100644 tests/iflet.bth create mode 100644 tests/iflet.out create mode 100644 tests/letstar.bth create mode 100644 tests/sumrec.bth create mode 100644 tests/sumrec.out create mode 100644 tests/whilelet.bth create mode 100644 tests/whilelet.out (limited to 'tests') diff --git a/tests/flet.bth b/tests/flet.bth new file mode 100644 index 0000000..102fc34 --- /dev/null +++ b/tests/flet.bth @@ -0,0 +1,7 @@ +(set f1 (fn (a b c) (say (* a (+ b c))))) +(set f2 (fn (a) (say (* a a)))) +(if true + (f1 6 2 4) + (f2 7)) +(let (a 100 b 200 c 300) + (say b)) diff --git a/tests/flet.out b/tests/flet.out new file mode 100644 index 0000000..7ba6bc8 --- /dev/null +++ b/tests/flet.out @@ -0,0 +1,2 @@ +36 +200 diff --git a/tests/iflet.bth b/tests/iflet.bth new file mode 100644 index 0000000..b461a5f --- /dev/null +++ b/tests/iflet.bth @@ -0,0 +1,8 @@ +(do + (if (< 2 3) + "yes" + "no") + (let (a 100 + b 200 + c 300) + (say b))) diff --git a/tests/iflet.out b/tests/iflet.out new file mode 100644 index 0000000..08839f6 --- /dev/null +++ b/tests/iflet.out @@ -0,0 +1 @@ +200 diff --git a/tests/letstar.bth b/tests/letstar.bth new file mode 100644 index 0000000..03d4305 --- /dev/null +++ b/tests/letstar.bth @@ -0,0 +1,4 @@ +(say (let (a 100) + (let (a 200 + b (/ a 10)) + (+ a b)))) diff --git a/tests/sumrec.bth b/tests/sumrec.bth new file mode 100644 index 0000000..8c8804a --- /dev/null +++ b/tests/sumrec.bth @@ -0,0 +1,7 @@ +(set f' (fn (x acc) + (if (< x 1) + acc + (f' (- x 1) (+ acc x))))) +(set f (fn (x) (f' x 0))) +(say (f 10)) +(say (f 100)) diff --git a/tests/sumrec.out b/tests/sumrec.out new file mode 100644 index 0000000..e613215 --- /dev/null +++ b/tests/sumrec.out @@ -0,0 +1,2 @@ +55 +5050 diff --git a/tests/whilelet.bth b/tests/whilelet.bth new file mode 100644 index 0000000..ce8a482 --- /dev/null +++ b/tests/whilelet.bth @@ -0,0 +1,11 @@ +(do + (let (i 0 + a []) + (while (< i 10) + (append a i) + (set i (+ i 1))) + (let (x 100 + y 200 + z 300) + (say y)) + (say a))) diff --git a/tests/whilelet.out b/tests/whilelet.out new file mode 100644 index 0000000..013e367 --- /dev/null +++ b/tests/whilelet.out @@ -0,0 +1,2 @@ +200 +[ 0 1 2 3 4 5 6 7 8 9 ] -- cgit v1.2.3