From a72ff678da253fce46e8e4648f6e4cf5ce1ea9b4 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 10 Mar 2024 21:39:53 -0500 Subject: uh new start --- test.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test.lua (limited to 'test.lua') diff --git a/test.lua b/test.lua new file mode 100644 index 0000000..ce8c034 --- /dev/null +++ b/test.lua @@ -0,0 +1,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 -- cgit 1.4.1-21-gabe81