diff options
author | SoniEx2 <endermoneymod@gmail.com> | 2019-07-30 21:12:16 -0300 |
---|---|---|
committer | SoniEx2 <endermoneymod@gmail.com> | 2019-07-30 21:12:16 -0300 |
commit | 4b365cdab1296bc88509c6f8610318adefb0ef0e (patch) | |
tree | 528741562b21cc0d81d7c71aca3eaee5e8433934 /testc.lua | |
parent | af3acfbb80bca7447af9fe0d4a34cf860163b218 (diff) |
It... kinda works?
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)) |