--- lam.test local test = {} local eval = require("eval").eval local read = require("read").read local luatype = require("type").luatype function test.test (form, expected) local diag = string.format("%s == %s", form, expected) local value = eval(read(form)) if value == expected then print(string.format("ok: %s", diag)) else print(string.format("not ok: %s != %s", diag, value)) end end function test.runtests () for name, fn in pairs(test) do if luatype(fn) == "function" and name ~= "test" and name ~= "runtests" then print(">>>", name) fn() end end end function test.lambda () test.test([[((lambda (x) (+ x x)) 3)]], 6) test.test([[((lambda () 100))]], 100) test.test([[((lambda (x) 1 2 3) 4)]], 3) test.test([[((lambda () 1 2 3))]], 3) test.test([[((lambda (x) x (+ x x) (+ x x x)) 9)]], 27) end --- return test