diff options
author | Case Duckworth | 2024-03-10 21:39:53 -0500 |
---|---|---|
committer | Case Duckworth | 2024-03-10 21:39:53 -0500 |
commit | a72ff678da253fce46e8e4648f6e4cf5ce1ea9b4 (patch) | |
tree | a82501fca97f4adc272d05145548d10cabe3ea2a /test.lua | |
parent | Ugghhhh totally not working (diff) | |
download | lam-a72ff678da253fce46e8e4648f6e4cf5ce1ea9b4.tar.gz lam-a72ff678da253fce46e8e4648f6e4cf5ce1ea9b4.zip |
uh new start
Diffstat (limited to 'test.lua')
-rw-r--r-- | test.lua | 28 |
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 | |||
4 | local test = {} | ||
5 | local eval = require("eval").eval | ||
6 | local read = require("read").read | ||
7 | |||
8 | function 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 | ||
25 | end | ||
26 | |||
27 | --- | ||
28 | return test | ||