diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2012-05-13 21:01:43 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2012-05-13 21:01:43 +0100 |
commit | 5b497fab972a8f22963b9c76b36b7d2ed6689711 (patch) | |
tree | 4308667646617856bfb718d750ed618a40a1da43 | |
parent | 63749400c33680ca1e4ad825873d2e60bb39eecb (diff) | |
download | lace-5b497fab972a8f22963b9c76b36b7d2ed6689711.tar.gz |
Change builtin default to store a _return rule ready for use
-rw-r--r-- | lib/lace/builtin.lua | 2 | ||||
-rw-r--r-- | test/test-lace.builtin.lua | 8 |
2 files changed, 3 insertions, 7 deletions
diff --git a/lib/lace/builtin.lua b/lib/lace/builtin.lua index 289f688..ff1cfd2 100644 --- a/lib/lace/builtin.lua +++ b/lib/lace/builtin.lua @@ -81,7 +81,7 @@ function builtin.default(compcontext, def, result, reason, unwanted) return compiler().error("Cannot change the default") end - compcontext[".lace"].default = { result, reason } + compcontext[".lace"].default = _return(compcontext, result, reason) return { fn = function() return true end, diff --git a/test/test-lace.builtin.lua b/test/test-lace.builtin.lua index 4da3bb2..558f15a 100644 --- a/test/test-lace.builtin.lua +++ b/test/test-lace.builtin.lua @@ -135,9 +135,7 @@ function suite.compile_builtin_default_ok() 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(#compctx[".lace"].default == 2, "Default table should consist of two entries") - assert(compctx[".lace"].default[1] == "allow", "First entry should be the result") - assert(compctx[".lace"].default[2] == "because", "Second entry should be the reason") + assert(type(compctx[".lace"].default.fn) == "function", "Default table should have a function like a rule") end function suite.compile_builtin_default_twice() @@ -159,9 +157,7 @@ function suite.compile_builtin_default_noreason() 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(#compctx[".lace"].default == 2, "Default table should consist of two entries") - assert(compctx[".lace"].default[1] == "allow", "First entry should be the result") - assert(compctx[".lace"].default[2] == "Default behaviour", "Second entry should be the reason") + assert(type(compctx[".lace"].default.fn) == "function", "Default table should have a function like a rule") end |