summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2024-06-27 12:01:33 +0100
committerubq323 <ubq323@ubq323.website>2024-06-27 12:05:27 +0100
commit991e694b558691264f82d80a7aa1b86ef3d2c92c (patch)
tree881946b076bdcc6545aa167ef7d544b6e16f9abb /tests
parenta559125a2d7af771784614b7a2092cc7fb707345 (diff)
more tests
Diffstat (limited to 'tests')
-rw-r--r--tests/flet.bth7
-rw-r--r--tests/flet.out2
-rw-r--r--tests/iflet.bth8
-rw-r--r--tests/iflet.out1
-rw-r--r--tests/letstar.bth4
-rw-r--r--tests/sumrec.bth7
-rw-r--r--tests/sumrec.out2
-rw-r--r--tests/whilelet.bth11
-rw-r--r--tests/whilelet.out2
9 files changed, 44 insertions, 0 deletions
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 ]