summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2016-06-25 15:53:08 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2016-06-25 15:53:08 +0100
commit88e13e3bca052cefaa941e6a51d7ae2717b5b25a (patch)
treec21078f3b62fc8b71cf162a5c70c7cb3526b483b
parent3fd981e84a24b4b866842cd333110a95647b94e8 (diff)
downloadtongue-88e13e3bca052cefaa941e6a51d7ae2717b5b25a.tar.bz2
Add a function token test and fix add_token
-rw-r--r--lib/tongue/langpack.lua1
-rw-r--r--test/test-tongue.langpack.lua8
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/tongue/langpack.lua b/lib/tongue/langpack.lua
index a2c0e24..b9a22d1 100644
--- a/lib/tongue/langpack.lua
+++ b/lib/tongue/langpack.lua
@@ -97,6 +97,7 @@ function langpack:add_token(token, expansion, strict)
end
end
self.entries[token:upper()] = expansion
+ return true
end
--- Expand a token and arguments into a message.
diff --git a/test/test-tongue.langpack.lua b/test/test-tongue.langpack.lua
index 102dd6d..04f7050 100644
--- a/test/test-tongue.langpack.lua
+++ b/test/test-tongue.langpack.lua
@@ -52,6 +52,14 @@ function suite.tryparentfallback()
assert(string.find(expn, 'foo="bar"'), expn)
end
+function suite.add_function_expn()
+ local lang = tongue.langpack.create("en")
+ assert(lang, "Could not create language pack")
+ assert(lang:add_token("TEST", function(args) return args.foo end),
+ "Unable to add a function token")
+ assert(lang:expand("TEST",{foo="bar"}) == "bar", "Function tokens don't work")
+end
+
local count_ok = 0
for _, testname in ipairs(testnames) do
-- print("Run: " .. testname)