summaryrefslogtreecommitdiff
path: root/test/test-lace.compiler.lua
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2017-05-13 11:09:16 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2017-05-13 11:09:16 +0100
commitbfec2f726309b84da40aeed90752e3ded0f651b9 (patch)
tree4d0a0941dda40118957fcb245f255dfc06477215 /test/test-lace.compiler.lua
parent3b3dae2b6ad232e5c9b8d7d5d29e0c8aa3e22da1 (diff)
downloadlace-bfec2f726309b84da40aeed90752e3ded0f651b9.tar.gz
Test checking defines in anyof/allof
Diffstat (limited to 'test/test-lace.compiler.lua')
-rw-r--r--test/test-lace.compiler.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/test-lace.compiler.lua b/test/test-lace.compiler.lua
index 700d717..cca4fb8 100644
--- a/test/test-lace.compiler.lua
+++ b/test/test-lace.compiler.lua
@@ -239,6 +239,30 @@ function suite.error_in_define_anyof2()
assert(line4 == " ^^^^^ ^^^^^^^^^", "The fourth line highlights relevant words")
end
+function suite.error_in_define_anyof3()
+ local result, msg = compiler.compile(comp_context, "errorindefineanyof3")
+ 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("something"), "The first line must mention the error")
+ assert(line2 == "real-errorindefineanyof3 :: 3", "The third line is where the error happened")
+ assert(line3 == "define fish anyof something else", "The third line is the original line")
+ assert(line4 == " ^^^^^^^^^ ", "The fourth line highlights relevant words")
+end
+
+function suite.error_in_define_anyof4()
+ local result, msg = compiler.compile(comp_context, "errorindefineanyof4")
+ 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("else"), "The first line must mention the error")
+ assert(line2 == "real-errorindefineanyof4 :: 3", "The third line is where the error happened")
+ assert(line3 == "define fish anyof something else", "The third line is the original line")
+ assert(line4 == " ^^^^", "The fourth line highlights relevant words")
+end
+
function suite.error_in_allow_or_deny()
local result, msg = compiler.compile(comp_context, "errorinallow")
assert(result == false, "Errors compiling should return false")