summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/clos1.bth3
-rw-r--r--tests/clos1.out1
-rw-r--r--tests/clos2.bth15
-rw-r--r--tests/clos2.out6
-rw-r--r--tests/clos3.bth16
-rw-r--r--tests/clos3.out8
-rw-r--r--tests/clos4.bth29
-rw-r--r--tests/clos4.out8
-rw-r--r--tests/defn.out1
9 files changed, 87 insertions, 0 deletions
diff --git a/tests/clos1.bth b/tests/clos1.bth
new file mode 100644
index 0000000..4c8f5d6
--- /dev/null
+++ b/tests/clos1.bth
@@ -0,0 +1,3 @@
+(def x 100)
+(defn (f) x)
+(say (f))
diff --git a/tests/clos1.out b/tests/clos1.out
new file mode 100644
index 0000000..29d6383
--- /dev/null
+++ b/tests/clos1.out
@@ -0,0 +1 @@
+100
diff --git a/tests/clos2.bth b/tests/clos2.bth
new file mode 100644
index 0000000..9e1fe24
--- /dev/null
+++ b/tests/clos2.bth
@@ -0,0 +1,15 @@
+(defn (k1 x)
+ (fn () x))
+(defn (k2 x)
+ (let (v x)
+ (fn () v)))
+(def a1 (k1 100))
+(def a2 (k2 200))
+(def b1 (k1 "hello 1"))
+(def b2 (k2 "hello 2"))
+(say (a1))
+(say (a2))
+(say (b1))
+(say (b2))
+(say (a1))
+(say (a2))
diff --git a/tests/clos2.out b/tests/clos2.out
new file mode 100644
index 0000000..e1f3c0f
--- /dev/null
+++ b/tests/clos2.out
@@ -0,0 +1,6 @@
+100
+200
+hello 1
+hello 2
+100
+200
diff --git a/tests/clos3.bth b/tests/clos3.bth
new file mode 100644
index 0000000..4742391
--- /dev/null
+++ b/tests/clos3.bth
@@ -0,0 +1,16 @@
+(defn (counter)
+ (let (a 0)
+ (fn ()
+ (set a (+ a 1))
+ (say a))))
+(def c1 (counter))
+(def c2 (counter))
+(c1)
+(c1)
+(c2)
+(c2)
+(c2)
+(c2)
+(c1)
+(c1)
+
diff --git a/tests/clos3.out b/tests/clos3.out
new file mode 100644
index 0000000..f55baa4
--- /dev/null
+++ b/tests/clos3.out
@@ -0,0 +1,8 @@
+1
+2
+1
+2
+3
+4
+3
+4
diff --git a/tests/clos4.bth b/tests/clos4.bth
new file mode 100644
index 0000000..c9a2092
--- /dev/null
+++ b/tests/clos4.bth
@@ -0,0 +1,29 @@
+(defn (f)
+ (let (a 0)
+ (defn (s x) (set a x))
+ (defn (g) a)
+ [s g]))
+
+
+(def a1 (f))
+(def s1 (a1 0))
+(def g1 (a1 1))
+
+(def a2 (f))
+(def s2 (a2 0))
+(def g2 (a2 1))
+
+(say (g1))
+(say (g2))
+
+(s1 6)
+(say (g1))
+(say (g2))
+
+(s2 70)
+(say (g1))
+(say (g2))
+
+(s2 (* (g1) (g1)))
+(say (g1))
+(say (g2))
diff --git a/tests/clos4.out b/tests/clos4.out
new file mode 100644
index 0000000..2c138e9
--- /dev/null
+++ b/tests/clos4.out
@@ -0,0 +1,8 @@
+0
+0
+6
+0
+6
+70
+6
+36
diff --git a/tests/defn.out b/tests/defn.out
new file mode 100644
index 0000000..a29644e
--- /dev/null
+++ b/tests/defn.out
@@ -0,0 +1 @@
+144