From 4b365cdab1296bc88509c6f8610318adefb0ef0e Mon Sep 17 00:00:00 2001 From: SoniEx2 Date: Tue, 30 Jul 2019 21:12:16 -0300 Subject: It... kinda works? --- testc.lua | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'testc.lua') 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)) -- cgit 1.4.1