summaryrefslogtreecommitdiff
path: root/test/test-lace.engine.lua
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2015-11-10 07:56:30 +0000
committerDaniel Silverstone <dsilvers@digital-scurf.org>2015-11-10 07:56:30 +0000
commite35d5fe83fbce97f7ff110e62cb503406f4a32f8 (patch)
treed60f456ca2deb7b4586fae9217ef7035a898fec6 /test/test-lace.engine.lua
parente7d8eb32504541c1f5549def12123b2375efa4e3 (diff)
downloadlace-e35d5fe83fbce97f7ff110e62cb503406f4a32f8.tar.bz2
Allow sub sub defines
Diffstat (limited to 'test/test-lace.engine.lua')
-rw-r--r--test/test-lace.engine.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/test-lace.engine.lua b/test/test-lace.engine.lua
index b3c38fd..e8721fc 100644
--- a/test/test-lace.engine.lua
+++ b/test/test-lace.engine.lua
@@ -266,6 +266,29 @@ function suite.subdefine_err_reported()
assert(line4 == " ^^^^^^^", "The fourth line highlights relevant words")
end
+function suite.subsubdefine_works()
+ local ruleset, msg = lace.compiler.compile(comp_context, "subsubdefine-works")
+ assert(type(ruleset) == "table", "Ruleset did not compile")
+ local ectx = {jeff = "geoff"}
+ local result, msg = lace.engine.run(ruleset, ectx)
+ assert(result, msg)
+ assert(result == "allow", "Result should be allow")
+ assert(msg == "PASS", "Message should be pass")
+end
+
+function suite.subsubdefine_err_reported()
+ local ruleset, msg = lace.compiler.compile(comp_context, "subsubdefine-error")
+ assert(type(ruleset) == "table", "Ruleset did not compile")
+ local ectx = {error = true}
+ local result, msg = lace.engine.run(ruleset, ectx)
+ assert(result == false, "Did not error out")
+ local line1, line2, line3, line4 = msg:match("^([^\n]*)\n([^\n]*)\n([^\n]*)\n([^\n]*)$")
+ assert(line1 == "woah", "The first line must mention the error")
+ assert(line2 == "real-subsubdefine-error :: 1", "The second line is where the error happened")
+ assert(line3 == 'allow "FAIL" {anyof {equal jeff banana} {error}}', "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)