diff options
Diffstat (limited to 'test/test-lace.compiler.lua')
-rw-r--r-- | test/test-lace.compiler.lua | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/test-lace.compiler.lua b/test/test-lace.compiler.lua index 8932243..42936eb 100644 --- a/test/test-lace.compiler.lua +++ b/test/test-lace.compiler.lua @@ -139,6 +139,11 @@ local comp_context = { commands = { DISABLEDCOMMAND = false, }, + controltype = { + nocompile = function() + return err.error("NOCOMPILE", {2}) + end, + }, }, } @@ -334,6 +339,43 @@ function suite.error_in_define4() assert(line4 == " ^^^^^^^^^^^^^^", "The fourth line highlights relevant words") end +function suite.error_in_define5() + local result, msg = compiler.compile(comp_context, "errorindefine5") + assert(result == false, "Errors compiling should return false") + assert(type(msg) == "string", "Compilation errors should be strings") + assert(msg:find("\n"), "Compilation errors are multiline") + local line1, line2, line3, line4 = msg:match("^([^\n]*)\n([^\n]*)\n([^\n]*)\n([^\n]*)$") + assert(line1:find("NOCOMPILE"), "The first line must mention the error") + assert(line2 == "real-errorindefine5 :: 3", "The second line is where the error happened") + assert(line3 == "define fish NOCOMPILE", "The third line is the original line") + assert(line4 == " ^^^^^^^^^", "The fourth line highlights relevant words") +end + +function suite.error_in_include1() + local result, msg = compiler.compile(comp_context, "errorininclude1") + assert(result == false, "Errors compiling should return false") + assert(type(msg) == "string", "Compilation errors should be strings") + assert(msg:find("\n"), "Compilation errors are multiline") + local line1, line2, line3, line4 = msg:match("^([^\n]*)\n([^\n]*)\n([^\n]*)\n([^\n]*)$") + assert(line1:find("No ruleset named"), "The first line must mention the error") + assert(line2 == "real-errorininclude1 :: 3", "The second line is where the error happened") + assert(line3 == "include", "The third line is the original line") + assert(line4 == "^^^^^^^", "The fourth line highlights relevant words") +end + +function suite.error_in_include2() + local result, msg = compiler.compile(comp_context, "errorininclude2") + assert(result == false, "Errors compiling should return false") + assert(type(msg) == "string", "Compilation errors should be strings") + assert(msg:find("\n"), "Compilation errors are multiline") + print(msg) + local line1, line2, line3, line4 = msg:match("^([^\n]*)\n([^\n]*)\n([^\n]*)\n([^\n]*)$") + assert(line1:find("NOTFOUND"), "The first line must mention the error") + assert(line2 == "real-errorininclude2 :: 3", "The second line is where the error happened") + assert(line3 == "include errorininclude2-NOTFOUND", "The third line is the original line") + assert(line4 == " ^^^^^^^^^^^^^^^^^^^^^^^^", "The fourth line highlights relevant words") +end + local count_ok = 0 for _, testname in ipairs(testnames) do -- print("Run: " .. testname) |