39 lines
1.1 KiB
Lua
39 lines
1.1 KiB
Lua
|
|
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_collect(target()) end, ...)
|
|
else
|
|
return realload(printr_collect(target), ...)
|
|
end
|
|
end
|
|
|
|
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")())))()
|
|
|
|
print("-----------------------------------------------------------------------------------------------------------------------")
|
|
print(table.concat(collect))
|