diff options
Diffstat (limited to 'testc.lua')
-rw-r--r-- | testc.lua | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/testc.lua b/testc.lua index 1c8f572..8abdcd5 100644 --- a/testc.lua +++ b/testc.lua @@ -1,17 +1,38 @@ + local function printr(...) print(...) return ... end +local collect = {} +local function printr_collect(...) + table.insert(collect, (...)) + return printr(...) +end + +-- used to print what the lua parser (load) is seeing, after cratera has done its thing +loadstring = nil local realload = load load = function(target, ...) if type(target) == "function" then - return realload(function() return printr(target()) end, ...) + return realload(function() return printr_collect(target()) end, ...) else - return realload(printr(target), ...) + return realload(printr_collect(target), ...) end end -local cratera = require "cratera" +local cratera = require "dirtycratera" + +-- first test: does it handle lua code properly? +assert(printr(cratera.load(io.lines("dirtycompiler.lua", "*a")())))() + +print("-----------------------------------------------------------------------------------------------------------------------") +print(table.concat(collect)) + +collect = {} + +-- second test: does it handle cratera tests properly? +assert(printr(cratera.load(io.lines("tests.cratera", "*a")())))() -assert(printr(cratera.load("")))() +print("-----------------------------------------------------------------------------------------------------------------------") +print(table.concat(collect)) |