summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2012-05-15 18:00:43 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2012-05-15 18:00:43 +0100
commite08b6d26ce6d1633e28ed5f2a90f0b8463023083 (patch)
tree3db13bc8a64007ac5a802a58dbffa672c5cd601f
parente02eafd845f786282559e11118a05cad41c09404 (diff)
downloadlace-e08b6d26ce6d1633e28ed5f2a90f0b8463023083.tar.gz
Use _lace instead of [".lace"]
-rw-r--r--doc/compiling8
-rw-r--r--doc/execution2
-rw-r--r--lib/lace/builtin.lua6
-rw-r--r--lib/lace/compiler.lua16
-rw-r--r--lib/lace/engine.lua4
-rw-r--r--test/test-lace.builtin.lua110
-rw-r--r--test/test-lace.compiler.lua18
-rw-r--r--test/test-lace.engine.lua8
8 files changed, 86 insertions, 86 deletions
diff --git a/doc/compiling b/doc/compiling
index ef80852..32ac930 100644
--- a/doc/compiling
+++ b/doc/compiling
@@ -5,7 +5,7 @@ When you construct a Lace engine, you give it a compilation callback
set. That set is used to call you back when Lace encounters something it
needs help compiling. The structure of it is:
-{ [".lace"] = {
+{ _lace = {
loader = function(compcontext, nametoload) ... end,
commands = {
... = function(compcontext, words...) ... end,
@@ -15,18 +15,18 @@ needs help compiling. The structure of it is:
}
} }
-Anything outside of the ".lace" entry in the context is considered
+Anything outside of the "_lace" entry in the context is considered
fair game structure-wise and can be used by the functions called back
to acquire internal pointers etc. Note however that the compilation
context will not be passed around during execution so if you need to
remember some of it in order to function properly, then it's up to
-you. Also note that anything not defined above in the ".lace" entry
+you. Also note that anything not defined above in the "_lace" entry
is considered "private" to Lace and should not be touched by non-Lace
code. Lace will usually be considerate and will not create arbitrary
entries in that table which do not start with a dot. This allows for
forward/backward compatibility to some extent.
-In addition, Lace will maintain a 'source' entry in the .lace table
+In addition, Lace will maintain a 'source' entry in the _lace table
with the lexed source which is being compiled and, if we're compiling
an included source, a parent entry with the compilation context of the
parent. The toplevel field is the compilation context of the top
diff --git a/doc/execution b/doc/execution
index f17ca1e..9b89590 100644
--- a/doc/execution
+++ b/doc/execution
@@ -3,7 +3,7 @@ Execution of Lace rulesets
Once compiled, a ruleset is essentially a sequence of functions to
call on the execution context. The simplest execution context is an
-empty table. If Lace is going to store anything it will use a ".lace"
+empty table. If Lace is going to store anything it will use a "_lace"
prefix as with compilation contexts.
A few important functions make up the execution engine. The top level
diff --git a/lib/lace/builtin.lua b/lib/lace/builtin.lua
index 71d5010..74cd34b 100644
--- a/lib/lace/builtin.lua
+++ b/lib/lace/builtin.lua
@@ -115,12 +115,12 @@ function builtin.default(compcontext, def, result, reason, unwanted)
return compiler().error("Unexpected additional content", {4})
end
- if compcontext[".lace"].default then
+ if compcontext._lace.default then
return compiler().error("Cannot change the default")
end
local uncond, last = unconditional_result, last_result
- compcontext[".lace"].default = _return(compcontext, result, reason)
+ compcontext._lace.default = _return(compcontext, result, reason)
unconditional_result, last_result = uncond, last
return {
@@ -153,7 +153,7 @@ local builtin_control_fn = {
--[ Definitions ]----------------------------------------------------
local function _controlfn(ctx, name)
- local ctt = ctx[".lace"].controltype or {}
+ local ctt = ctx._lace.controltype or {}
local cfn = ctt[name]
if cfn == nil then
cfn = builtin_control_fn[name]
diff --git a/lib/lace/compiler.lua b/lib/lace/compiler.lua
index e7d1854..d1178f0 100644
--- a/lib/lace/compiler.lua
+++ b/lib/lace/compiler.lua
@@ -26,13 +26,13 @@ local function _loader(ctx)
-- We know the context is a table with a .lace table, so retrieve
-- the loader function. If it's absent, return a loader which
-- fails due to no loader being present.
- return ctx[".lace"].loader or _fake_loader
+ return ctx._lace.loader or _fake_loader
end
local function _command(ctx, name)
-- While we know .lace is present, there's no guarantee they added
-- any commands
- local cmdtab = ctx[".lace"].commands or {}
+ local cmdtab = ctx._lace.commands or {}
local cfn = cmdtab[name]
if cfn == nil then
cfn = builtin.commands[name]
@@ -48,8 +48,8 @@ local function _normalise_error(ctx, err)
end
local function _setposition(context, ruleset, linenr)
- context[".lace"].source = (ruleset or {}).content
- context[".lace"].linenr = linenr
+ context._lace.source = (ruleset or {}).content
+ context._lace.linenr = linenr
end
local function compile_one_line(compcontext, line)
@@ -71,7 +71,7 @@ end
local function internal_compile_ruleset(compcontext, sourcename, content, suppress_default)
assert(type(compcontext) == "table", "Compilation context must be a table")
- assert(type(compcontext[".lace"]) == "table", "Compilation context must contain a .lace table")
+ assert(type(compcontext._lace) == "table", "Compilation context must contain a .lace table")
assert(type(sourcename) == "string", "Source name must be a string")
assert(content == nil or type(content) == "string", "Content must be nil or a string")
if not content then
@@ -98,7 +98,7 @@ local function internal_compile_ruleset(compcontext, sourcename, content, suppre
if not suppress_default then
-- Ensure there's no default present before processing.
-- We only suppress inside includes
- compcontext[".lace"].default = nil
+ compcontext._lace.default = nil
end
for i = 1, #lexed_content.lines do
@@ -131,13 +131,13 @@ local function internal_compile_ruleset(compcontext, sourcename, content, suppre
end
if not suppress_default and not uncond then
- if not compcontext[".lace"].default then
+ if not compcontext._lace.default then
-- No default, fake one up
builtin.commands.default(compcontext, "default",
result == "allow" and "deny" or "allow")
end
-- Now, inject the default command at the end of the ruleset.
- ruleset.rules[#ruleset.rules+1] = compcontext[".lace"].default
+ ruleset.rules[#ruleset.rules+1] = compcontext._lace.default
end
_setposition(compcontext)
diff --git a/lib/lace/engine.lua b/lib/lace/engine.lua
index 123af7a..b72db5f 100644
--- a/lib/lace/engine.lua
+++ b/lib/lace/engine.lua
@@ -12,8 +12,8 @@ local function _error(str, words)
end
local function _dlace(ctx)
- local ret = ctx[".lace"] or {}
- ctx[".lace"] = ret
+ local ret = ctx._lace or {}
+ ctx._lace = ret
return ret
end
diff --git a/test/test-lace.builtin.lua b/test/test-lace.builtin.lua
index 4ee79c2..913843b 100644
--- a/test/test-lace.builtin.lua
+++ b/test/test-lace.builtin.lua
@@ -102,7 +102,7 @@ function suite.run_builtin_allow_deny_conditional_saved()
end
function suite.compile_builtin_default_noresult()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.default(compctx, "default")
assert(cmdtab == false, "Internal errors should return false")
assert(type(msg) == "table", "Internal errors should return tables")
@@ -111,7 +111,7 @@ function suite.compile_builtin_default_noresult()
end
function suite.compile_builtin_default_resultbad()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.default(compctx, "default", "FISH")
assert(cmdtab == false, "Internal errors should return false")
assert(type(msg) == "table", "Internal errors should return tables")
@@ -120,7 +120,7 @@ function suite.compile_builtin_default_resultbad()
end
function suite.compile_builtin_default_extra_fluff()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.default(compctx, "default", "allow", "", "unwanted")
assert(cmdtab == false, "Internal errors should return false")
assert(type(msg) == "table", "Internal errors should return tables")
@@ -129,18 +129,18 @@ function suite.compile_builtin_default_extra_fluff()
end
function suite.compile_builtin_default_ok()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.default(compctx, "default", "allow", "because")
assert(type(cmdtab) == "table", "Successful compilation should return a table")
assert(type(cmdtab.fn) == "function", "With a function")
assert(type(cmdtab.args) == "table", "And an arg table")
assert(cmdtab.fn() == true, "Default command should always return true")
- assert(type(compctx[".lace"].default) == "table", "Default should always set up the context")
- assert(type(compctx[".lace"].default.fn) == "function", "Default table should have a function like a rule")
+ assert(type(compctx._lace.default) == "table", "Default should always set up the context")
+ assert(type(compctx._lace.default.fn) == "function", "Default table should have a function like a rule")
end
function suite.compile_builtin_default_twice()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.default(compctx, "default", "allow", "")
assert(type(cmdtab) == "table", "Successful compilation should return a table")
local cmdtab, msg = builtin.commands.default(compctx, "default", "allow", "")
@@ -151,18 +151,18 @@ function suite.compile_builtin_default_twice()
end
function suite.compile_builtin_default_noreason()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.default(compctx, "default", "allow")
assert(type(cmdtab) == "table", "Successful compilation should return a table")
assert(type(cmdtab.fn) == "function", "With a function")
assert(type(cmdtab.args) == "table", "And an arg table")
assert(cmdtab.fn() == true, "Default command should always return true")
- assert(type(compctx[".lace"].default) == "table", "Default should always set up the context")
- assert(type(compctx[".lace"].default.fn) == "function", "Default table should have a function like a rule")
+ assert(type(compctx._lace.default) == "table", "Default should always set up the context")
+ assert(type(compctx._lace.default.fn) == "function", "Default table should have a function like a rule")
end
function suite.compile_builtin_define_noname()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.define(compctx, "define")
assert(cmdtab == false, "Internal errors should return false")
assert(type(msg) == "table", "Internal errors should return tables")
@@ -171,7 +171,7 @@ function suite.compile_builtin_define_noname()
end
function suite.compile_builtin_define_badname()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.define(compctx, "define", "!fish")
assert(cmdtab == false, "Internal errors should return false")
assert(type(msg) == "table", "Internal errors should return tables")
@@ -180,7 +180,7 @@ function suite.compile_builtin_define_badname()
end
function suite.compile_builtin_define_noctype()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.define(compctx, "define", "fish")
assert(cmdtab == false, "Internal errors should return false")
assert(type(msg) == "table", "Internal errors should return tables")
@@ -189,7 +189,7 @@ function suite.compile_builtin_define_noctype()
end
function suite.compile_builtin_define_badctype()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.define(compctx, "define", "fish", "fish")
assert(cmdtab == false, "Internal errors should return false")
assert(type(msg) == "table", "Internal errors should return tables")
@@ -201,7 +201,7 @@ function suite.compile_builtin_define_ctype_errors()
local function _fish()
return false, { msg = "Argh" }
end
- local compctx = {[".lace"] = { controltype = { fish = _fish }}}
+ local compctx = {_lace = { controltype = { fish = _fish }}}
local cmdtab, msg = builtin.commands.define(compctx, "define", "fish", "fish")
assert(cmdtab == false, "Internal errors should return false")
assert(type(msg) == "table", "Internal errors should return tables")
@@ -213,7 +213,7 @@ function suite.compile_builtin_define_ctype_errors_offset()
local function _fish()
return false, { msg = "Argh", words = {0} }
end
- local compctx = {[".lace"] = { controltype = { fish = _fish }}}
+ local compctx = {_lace = { controltype = { fish = _fish }}}
local cmdtab, msg = builtin.commands.define(compctx, "define", "fish", "fish")
assert(cmdtab == false, "Internal errors should return false")
assert(type(msg) == "table", "Internal errors should return tables")
@@ -228,18 +228,18 @@ function suite.compile_builtin_define_ok()
JEFF = true
}
end
- local compctx = {[".lace"] = { controltype = { fish = _fish }}}
+ local compctx = {_lace = { controltype = { fish = _fish }}}
local cmdtab, msg = builtin.commands.define(compctx, "define", "fish", "fish")
assert(type(cmdtab) == "table", "Successful compilation returns tables")
assert(type(cmdtab.fn) == "function", "With functions")
local ectx = {}
local ok, msg = cmdtab.fn(ectx, unpack(cmdtab.args))
assert(ok, "Running a define should work")
- assert(ectx[".lace"].defs.fish.JEFF, "definition should have passed through")
+ assert(ectx._lace.defs.fish.JEFF, "definition should have passed through")
end
function suite.run_allow_deny_with_conditions_not_present()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.allow(compctx, "allow", "because", "cheese")
assert(type(cmdtab) == "table", "Successful compilation returns tables")
assert(type(cmdtab.fn) == "function", "With functions")
@@ -250,7 +250,7 @@ function suite.run_allow_deny_with_conditions_not_present()
end
function suite.run_allow_deny_with_condition_present_erroring()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.allow(compctx, "allow", "because", "cheese")
assert(type(cmdtab) == "table", "Successful compilation returns tables")
assert(type(cmdtab.fn) == "function", "With functions")
@@ -258,14 +258,14 @@ function suite.run_allow_deny_with_condition_present_erroring()
fn = function() return nil, { msg = "CHEESE" } end,
args = {}
}
- local ectx = {[".lace"] = {defs = { cheese = _cheesetab }}}
+ local ectx = {_lace = {defs = { cheese = _cheesetab }}}
local ok, msg = cmdtab.fn(ectx, unpack(cmdtab.args))
assert(ok == nil, "Running a conditional allow where the conditions error should fail")
assert(msg.msg:match("CHEESE"), "Resultant error should be passed")
end
function suite.run_allow_deny_with_condition_present_failing()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.allow(compctx, "allow", "because", "cheese")
assert(type(cmdtab) == "table", "Successful compilation returns tables")
assert(type(cmdtab.fn) == "function", "With functions")
@@ -273,14 +273,14 @@ function suite.run_allow_deny_with_condition_present_failing()
fn = function() return false end,
args = {}
}
- local ectx = {[".lace"] = {defs = { cheese = _cheesetab }}}
+ local ectx = {_lace = {defs = { cheese = _cheesetab }}}
local ok, msg = cmdtab.fn(ectx, unpack(cmdtab.args))
assert(ok == true, "Running a conditional allow where the conditions fail should return continuation")
end
function suite.run_allow_deny_with_condition_present_passing()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.allow(compctx, "allow", "because", "cheese")
assert(type(cmdtab) == "table", "Successful compilation returns tables")
assert(type(cmdtab.fn) == "function", "With functions")
@@ -288,14 +288,14 @@ function suite.run_allow_deny_with_condition_present_passing()
fn = function() return true end,
args = {}
}
- local ectx = {[".lace"] = {defs = { cheese = _cheesetab }}}
+ local ectx = {_lace = {defs = { cheese = _cheesetab }}}
local ok, msg = cmdtab.fn(ectx, unpack(cmdtab.args))
assert(ok == "allow", "Running a conditional allow where the conditions pass should return allow")
assert(msg == "because", "Resulting in the reason given")
end
function suite.run_allow_deny_with_inverted_condition_present_failing()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.allow(compctx, "allow", "because", "!cheese")
assert(type(cmdtab) == "table", "Successful compilation returns tables")
assert(type(cmdtab.fn) == "function", "With functions")
@@ -303,14 +303,14 @@ function suite.run_allow_deny_with_inverted_condition_present_failing()
fn = function() return true end,
args = {}
}
- local ectx = {[".lace"] = {defs = { cheese = _cheesetab }}}
+ local ectx = {_lace = {defs = { cheese = _cheesetab }}}
local ok, msg = cmdtab.fn(ectx, unpack(cmdtab.args))
assert(ok == true, "Running a conditional allow where the conditions fail should return continuation")
end
function suite.run_allow_deny_with_inverted_condition_present_passing()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.allow(compctx, "allow", "because", "!cheese")
assert(type(cmdtab) == "table", "Successful compilation returns tables")
assert(type(cmdtab.fn) == "function", "With functions")
@@ -318,14 +318,14 @@ function suite.run_allow_deny_with_inverted_condition_present_passing()
fn = function() return false end,
args = {}
}
- local ectx = {[".lace"] = {defs = { cheese = _cheesetab }}}
+ local ectx = {_lace = {defs = { cheese = _cheesetab }}}
local ok, msg = cmdtab.fn(ectx, unpack(cmdtab.args))
assert(ok == "allow", "Running a conditional allow where the conditions pass should return allow")
assert(msg == "because", "Resulting in the reason given")
end
function suite.compile_include_statement_noname()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.include(compctx, "include")
assert(cmdtab == false, "Internal errors should return false")
assert(type(msg) == "table", "Internal errors should return tables")
@@ -334,7 +334,7 @@ function suite.compile_include_statement_noname()
end
function suite.compile_include_statement_noloader()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.include(compctx, "include", "fish")
assert(cmdtab == false, "Internal errors should return false")
assert(type(msg) == "table", "Internal errors should return tables")
@@ -343,7 +343,7 @@ function suite.compile_include_statement_noloader()
end
function suite.compile_safe_include_statement_noloader()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.include(compctx, "include?", "fish")
assert(type(cmdtab) == "table", "Commands should be tables")
assert(type(cmdtab.fn) == "function", "With a function")
@@ -354,7 +354,7 @@ function suite.compile_include_statement_withloader()
local function _loader(cctx, name)
return name, "-- nada\n"
end
- local compctx = {[".lace"] = {loader=_loader}}
+ local compctx = {_lace = {loader=_loader}}
local cmdtab, msg = builtin.commands.include(compctx, "include", "fish")
assert(type(cmdtab) == "table", "Commands should be tables")
assert(type(cmdtab.fn) == "function", "With a function")
@@ -365,7 +365,7 @@ function suite.compile_include_statement_withloader_badcode()
local function _loader(cctx, name)
return name, "nada\n"
end
- local compctx = {[".lace"] = {loader=_loader}}
+ local compctx = {_lace = {loader=_loader}}
local cmdtab, msg = builtin.commands.include(compctx, "include", "fish")
assert(cmdtab == false, "Internal errors should return false")
assert(type(msg) == "table", "Internal errors should return tables")
@@ -377,7 +377,7 @@ function suite.run_include_statement_withloader_good_code()
local function _loader(cctx, name)
return name, "--nada\n"
end
- local compctx = {[".lace"] = {loader=_loader}}
+ local compctx = {_lace = {loader=_loader}}
local cmdtab, msg = builtin.commands.include(compctx, "include", "fish")
assert(type(cmdtab) == "table", "Commands should be tables")
assert(type(cmdtab.fn) == "function", "With a function")
@@ -391,7 +391,7 @@ function suite.run_include_statement_withloader_good_code_allow()
local function _loader(cctx, name)
return name, "allow because\n"
end
- local compctx = {[".lace"] = {loader=_loader}}
+ local compctx = {_lace = {loader=_loader}}
local cmdtab, msg = builtin.commands.include(compctx, "include", "fish")
assert(type(cmdtab) == "table", "Commands should be tables")
assert(type(cmdtab.fn) == "function", "With a function")
@@ -406,7 +406,7 @@ function suite.run_cond_include_present_erroring()
local function _loader(cctx, name)
return name, "allow because\n"
end
- local compctx = {[".lace"] = {loader=_loader}}
+ local compctx = {_lace = {loader=_loader}}
local cmdtab, msg = builtin.commands.include(compctx, "include", "fish", "cheese")
assert(type(cmdtab) == "table", "Commands should be tables")
assert(type(cmdtab.fn) == "function", "With a function")
@@ -421,13 +421,13 @@ function suite.run_cond_include_present_erroring()
local function _loader(cctx, name)
return name, "allow because\n"
end
- local compctx = {[".lace"] = {loader=_loader}}
+ local compctx = {_lace = {loader=_loader}}
local cmdtab, msg = builtin.commands.include(compctx, "include", "fish", "cheese")
assert(type(cmdtab) == "table", "Commands should be tables")
assert(type(cmdtab.fn) == "function", "With a function")
assert(type(cmdtab.args) == "table", "and arguments")
local ectx = {
- [".lace"] = {
+ _lace = {
defs = {
cheese = {
fn = function() return nil, { msg = "FAIL" } end,
@@ -445,13 +445,13 @@ function suite.run_cond_include_present_failing()
local function _loader(cctx, name)
return name, "allow because\n"
end
- local compctx = {[".lace"] = {loader=_loader}}
+ local compctx = {_lace = {loader=_loader}}
local cmdtab, msg = builtin.commands.include(compctx, "include", "fish", "cheese")
assert(type(cmdtab) == "table", "Commands should be tables")
assert(type(cmdtab.fn) == "function", "With a function")
assert(type(cmdtab.args) == "table", "and arguments")
local ectx = {
- [".lace"] = {
+ _lace = {
defs = {
cheese = {
fn = function() return false end,
@@ -468,13 +468,13 @@ function suite.run_cond_include_present_passing()
local function _loader(cctx, name)
return name, "allow because\n"
end
- local compctx = {[".lace"] = {loader=_loader}}
+ local compctx = {_lace = {loader=_loader}}
local cmdtab, msg = builtin.commands.include(compctx, "include", "fish", "cheese")
assert(type(cmdtab) == "table", "Commands should be tables")
assert(type(cmdtab.fn) == "function", "With a function")
assert(type(cmdtab.args) == "table", "and arguments")
local ectx = {
- [".lace"] = {
+ _lace = {
defs = {
cheese = {
fn = function() return true end,
@@ -489,7 +489,7 @@ function suite.run_cond_include_present_passing()
end
function suite.compile_anyof_no_args()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.define(compctx, "define", "foo", "anyof")
assert(cmdtab == false, "Internal errors should return false")
assert(type(msg) == "table", "Internal errors should be tables")
@@ -497,7 +497,7 @@ function suite.compile_anyof_no_args()
end
function suite.compile_allof_no_args()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.define(compctx, "define", "foo", "allof")
assert(cmdtab == false, "Internal errors should return false")
assert(type(msg) == "table", "Internal errors should be tables")
@@ -505,7 +505,7 @@ function suite.compile_allof_no_args()
end
function suite.compile_anyof_one_args()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.define(compctx, "define", "foo", "anyof", "foo")
assert(cmdtab == false, "Internal errors should return false")
assert(type(msg) == "table", "Internal errors should be tables")
@@ -513,7 +513,7 @@ function suite.compile_anyof_one_args()
end
function suite.compile_allof_one_args()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.define(compctx, "define", "foo", "allof", "foo")
assert(cmdtab == false, "Internal errors should return false")
assert(type(msg) == "table", "Internal errors should be tables")
@@ -522,7 +522,7 @@ end
function suite.compile_anyof_two_args()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.define(compctx, "define", "foo", "anyof", "foo", "bar")
assert(type(cmdtab) == "table", "Successful compilations should return tables")
assert(type(cmdtab.fn) == "function", "With functions")
@@ -541,7 +541,7 @@ function suite.compile_anyof_two_args()
end
function suite.compile_allof_two_args()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.define(compctx, "define", "foo", "allof", "foo", "bar")
assert(type(cmdtab) == "table", "Successful compilations should return tables")
assert(type(cmdtab.fn) == "function", "With functions")
@@ -560,11 +560,11 @@ function suite.compile_allof_two_args()
end
function suite.run_anyof_two_args()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.define(compctx, "define", "jeff", "anyof", "foo", "bar")
assert(type(cmdtab) == "table", "Successful compilations should return tables")
local ectx = {
- [".lace"] = {
+ _lace = {
defs = {
foo = {
fn = function() return true end,
@@ -579,16 +579,16 @@ function suite.run_anyof_two_args()
}
local ok, msg = cmdtab.fn(ectx, unpack(cmdtab.args))
assert(ok, "Running a define should work")
- assert(ectx[".lace"].defs.foo.fn, "definition should have passed through")
+ assert(ectx._lace.defs.foo.fn, "definition should have passed through")
assert(engine.test(ectx, "jeff"), "Any of true,false should be true")
end
function suite.run_anyof_two_args()
- local compctx = {[".lace"] = {}}
+ local compctx = {_lace = {}}
local cmdtab, msg = builtin.commands.define(compctx, "define", "jeff", "allof", "foo", "bar")
assert(type(cmdtab) == "table", "Successful compilations should return tables")
local ectx = {
- [".lace"] = {
+ _lace = {
defs = {
foo = {
fn = function() return true end,
@@ -603,7 +603,7 @@ function suite.run_anyof_two_args()
}
local ok, msg = cmdtab.fn(ectx, unpack(cmdtab.args))
assert(ok, "Running a define should work")
- assert(ectx[".lace"].defs.foo.fn, "definition should have passed through")
+ assert(ectx._lace.defs.foo.fn, "definition should have passed through")
assert(engine.test(ectx, "jeff") == false, "All of true,false should be false")
end
diff --git a/test/test-lace.compiler.lua b/test/test-lace.compiler.lua
index bebeae4..8a1c63b 100644
--- a/test/test-lace.compiler.lua
+++ b/test/test-lace.compiler.lua
@@ -35,37 +35,37 @@ function suite.context_missing_dot_lace()
end
function suite.context_dot_lace_not_table()
- local result, msg = compiler.compile({[".lace"] = true}, "")
+ local result, msg = compiler.compile({_lace = true}, "")
assert(result == nil, "Lua errors should return nil")
assert(msg:match("context must contain"), "Supposed to whinge about context missing .lace")
end
function suite.source_not_string()
- local result, msg = compiler.compile({[".lace"] = {}}, false)
+ local result, msg = compiler.compile({_lace = {}}, false)
assert(result == nil, "Lua errors should return nil")
assert(msg:match("name must be a string"), "Supposed to whinge about name not being a string")
end
function suite.content_not_string()
- local result, msg = compiler.compile({[".lace"] = {}}, "", false)
+ local result, msg = compiler.compile({_lace = {}}, "", false)
assert(result == nil, "Lua errors should return nil")
assert(msg:match("must be nil or a string"), "Supposed to whinge about content not being a string but being non-nil")
end
function suite.empty_content_no_loader()
- local result, msg = compiler.compile({[".lace"] = {}}, "", "")
+ local result, msg = compiler.compile({_lace = {}}, "", "")
assert(result == false, "Internal errors should return false")
assert(msg:match("whatsoever"), "Supposed to whinge about no allow/deny at all")
end
function suite.no_content_no_loader()
- local result, msg = compiler.compile({[".lace"] = {}}, "")
+ local result, msg = compiler.compile({_lace = {}}, "")
assert(result == false, "Internal errors should return false")
assert(msg:match("Ruleset not found:"), "Supposed to whinge about ruleset not being found")
end
function suite.no_unconditional_action()
- local result, msg = compiler.compile({[".lace"] = {}}, "", "deny stuff cond")
+ local result, msg = compiler.compile({_lace = {}}, "", "deny stuff cond")
assert(type(result) == "table", "Loading a ruleset should result in a table")
assert(#result.rules == 2, "There should be two rules present")
local rule = result.rules[1]
@@ -81,7 +81,7 @@ function suite.no_unconditional_action()
end
function suite.no_unconditional_action_default_deny()
- local result, msg = compiler.compile({[".lace"] = {}}, "", "default deny\ndeny stuff cond")
+ local result, msg = compiler.compile({_lace = {}}, "", "default deny\ndeny stuff cond")
assert(type(result) == "table", "Loading a ruleset should result in a table")
assert(#result.rules == 3, "There should be three rules present")
local rule = result.rules[1]
@@ -97,7 +97,7 @@ function suite.no_unconditional_action_default_deny()
end
function suite.is_unconditional_action_default_deny()
- local result, msg = compiler.compile({[".lace"] = {}}, "", "default deny\nallow stuff")
+ local result, msg = compiler.compile({_lace = {}}, "", "default deny\nallow stuff")
assert(type(result) == "table", "Loading a ruleset should result in a table")
assert(#result.rules == 2, "There should be two rules present")
local rule = result.rules[1]
@@ -115,7 +115,7 @@ end
-- Now we set up a more useful context and use that going forward:
local comp_context = {
- [".lace"] = {
+ _lace = {
loader = function(ctx, name)
if name == "THROW_ERROR" then
error("THROWN")
diff --git a/test/test-lace.engine.lua b/test/test-lace.engine.lua
index df8687a..a547280 100644
--- a/test/test-lace.engine.lua
+++ b/test/test-lace.engine.lua
@@ -67,7 +67,7 @@ function suite.check_bad_exec_fn_returns_nil()
local function _explode()
return { fn = function() error("EXPLODE") end, args = {} }
end
- local compctx = {[".lace"]={commands={explode=_explode}}}
+ local compctx = {_lace={commands={explode=_explode}}}
local ruleset, msg = lace.compiler.compile(compctx, "src", "explode\nallow because")
assert(type(ruleset) == "table", "Could not compile exploding ruleset")
local execctx = {}
@@ -80,7 +80,7 @@ function suite.check_error_propagates()
local function _explode()
return { fn = function() return false, "EXPLODE" end, args = {} }
end
- local compctx = {[".lace"]={commands={explode=_explode}}}
+ local compctx = {_lace={commands={explode=_explode}}}
local ruleset, msg = lace.compiler.compile(compctx, "src", "explode\nallow because")
assert(type(ruleset) == "table", "Could not compile exploding ruleset")
local execctx = {}
@@ -90,7 +90,7 @@ function suite.check_error_propagates()
end
function suite.check_deny_works()
- local compctx = {[".lace"]={}}
+ local compctx = {_lace={}}
local ruleset, msg = lace.compiler.compile(compctx, "src", "deny everything")
assert(type(ruleset) == "table", "Could not compile exploding ruleset")
local execctx = {}
@@ -102,7 +102,7 @@ end
-- More complete engine tests from here
local comp_context = {
- [".lace"] = {
+ _lace = {
loader = function(ctx, name)
if name == "THROW_ERROR" then
error("THROWN")