about summary refs log tree commit diff stats
path: root/test.lua
diff options
context:
space:
mode:
authorCase Duckworth2024-03-10 21:39:53 -0500
committerCase Duckworth2024-03-10 21:39:53 -0500
commita72ff678da253fce46e8e4648f6e4cf5ce1ea9b4 (patch)
treea82501fca97f4adc272d05145548d10cabe3ea2a /test.lua
parentUgghhhh totally not working (diff)
downloadlam-a72ff678da253fce46e8e4648f6e4cf5ce1ea9b4.tar.gz
lam-a72ff678da253fce46e8e4648f6e4cf5ce1ea9b4.zip
uh new start
Diffstat (limited to 'test.lua')
-rw-r--r--test.lua28
1 files changed, 28 insertions, 0 deletions
diff --git a/test.lua b/test.lua new file mode 100644 index 0000000..ce8c034 --- /dev/null +++ b/test.lua
@@ -0,0 +1,28 @@
1--- lam.test
2-- testing helpers
3
4local test = {}
5local eval = require("eval").eval
6local read = require("read").read
7
8function test.lambda ()
9 local ls = {
10 [ [[((lambda (x) (+ x x)) 3)]] ] = 6,
11 [ [[((lambda () 100))]] ] = 100,
12 [ [[((lambda (x) 1 2 3) 4)]] ] = 3,
13 [ [[((lambda () 1 2 3))]] ] = 3,
14 [ [[((lambda (x) x (+ x x) (+ x x x)) 9)]] ] = 27,
15 }
16 for l, target in pairs(ls) do
17 io.write(string.format("%s == %s\n\t", l, target))
18 local value = eval(read(l))
19 if value == target then
20 print "ok"
21 else
22 print(string.format("not ok : %s", value))
23 end
24 end
25end
26
27---
28return test