@@ -378,6 +378,40 @@ doTest("Macros", function()
378378 assert (not pp .processString { code = [[ !(function Y() outputLua("y") ; return "z" end) x = @@Y() ]] })
379379end )
380380
381+ doTest (" Predefined macros" , function ()
382+ local pp = ppChunk ()
383+
384+ -- @@ASSERT()
385+ local luaOut = assert (pp .processString { code = [[
386+ @@ASSERT(foo)
387+ ]] })
388+ assertCodeOutput (luaOut , [[ if not (foo) then error("Assertion failed: foo") end]] )
389+
390+ local luaOut = assert (pp .processString { code = [[
391+ @@ASSERT(foo ~= "bad", "Bad foo: "..foo)
392+ ]] })
393+ assertCodeOutput (luaOut , [[ if not (foo ~= "bad") then error(("Bad foo: "..foo)) end]] )
394+
395+ -- @@LOG()
396+ local luaOut = assert (pp .processString { logLevel = " error" , code = [[
397+ @@LOG("warning", "Uh oh!")
398+ ]] })
399+ assertCodeOutput (luaOut , [[ ]] )
400+
401+ local luaOut = assert (pp .processString { logLevel = " warning" , code = [[
402+ @@LOG("warning", "Uh oh!")
403+ ]] })
404+ assertCodeOutput (luaOut , [[ print("Uh oh!")]] )
405+
406+ local luaOut = assert (pp .processString { code = [[
407+ @@LOG("warning", "Number: %d", num)
408+ ]] })
409+ assertCodeOutput (luaOut , [[ print(string.format("Number: %d", num))]] )
410+
411+ -- Invalid: Bad log level.
412+ assert (not pp .processString { logLevel = " bad" , code = " " })
413+ end )
414+
381415doTest (" Preprocessor symbols" , function ()
382416 local pp = ppChunk ()
383417
0 commit comments