diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2017-05-13 11:09:16 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2017-05-13 11:09:16 +0100 |
commit | bfec2f726309b84da40aeed90752e3ded0f651b9 (patch) | |
tree | 4d0a0941dda40118957fcb245f255dfc06477215 | |
parent | 3b3dae2b6ad232e5c9b8d7d5d29e0c8aa3e22da1 (diff) | |
download | lace-bfec2f726309b84da40aeed90752e3ded0f651b9.tar.gz |
Test checking defines in anyof/allof
-rw-r--r-- | test/test-lace.compile-errorindefineanyof3.rules | 5 | ||||
-rw-r--r-- | test/test-lace.compile-errorindefineanyof4.rules | 5 | ||||
-rw-r--r-- | test/test-lace.compiler.lua | 24 |
3 files changed, 34 insertions, 0 deletions
diff --git a/test/test-lace.compile-errorindefineanyof3.rules b/test/test-lace.compile-errorindefineanyof3.rules new file mode 100644 index 0000000..9280c89 --- /dev/null +++ b/test/test-lace.compile-errorindefineanyof3.rules @@ -0,0 +1,5 @@ +-- Error in define anyof, expect an error on line 3 word 4 + +define fish anyof something else + +allow "anyway" diff --git a/test/test-lace.compile-errorindefineanyof4.rules b/test/test-lace.compile-errorindefineanyof4.rules new file mode 100644 index 0000000..99a6887 --- /dev/null +++ b/test/test-lace.compile-errorindefineanyof4.rules @@ -0,0 +1,5 @@ +-- Error in define anyof, expect an error on line 3 word 4 +define something equal foo +define fish anyof something else + +allow "anyway" 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") |