blob: ce8c034dc7adf3a4140527e27bd2c78ce9e0c0ef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
--- lam.test
-- testing helpers
local test = {}
local eval = require("eval").eval
local read = require("read").read
function test.lambda ()
local ls = {
[ [[((lambda (x) (+ x x)) 3)]] ] = 6,
[ [[((lambda () 100))]] ] = 100,
[ [[((lambda (x) 1 2 3) 4)]] ] = 3,
[ [[((lambda () 1 2 3))]] ] = 3,
[ [[((lambda (x) x (+ x x) (+ x x x)) 9)]] ] = 27,
}
for l, target in pairs(ls) do
io.write(string.format("%s == %s\n\t", l, target))
local value = eval(read(l))
if value == target then
print "ok"
else
print(string.format("not ok : %s", value))
end
end
end
---
return test
|