Module:User:Erutuon/zh-han/sandbox/testcases
Appearance
- The following documentation is located at Module:User:Erutuon/zh-han/sandbox/testcases/documentation. [edit]
- Useful links: root page • root page’s subpages • links • transclusions • tested module • sandbox of
Module error: No such module "zh-han/sandbox/testcases".
Lua error in Module:module_categorization at line 298: Could not infer any languages or scripts from root pagename 'User:Erutuon'
local tests = require "Module:UnitTests"
local as_and_sn_codes = {
c = 'simplified Chinese', t = 'traditional Chinese', m = 'mainland Chinese',
j = 'Japanese', k = 'Korean',
}
local sorted_pairs = require "Module:table".sortedPairs
local function print_parameters(parameters)
local output = require "Module:array"()
for k, v in sorted_pairs(parameters) do
output:insert(mw.text.nowiki "|" .. k .. "=" .. v)
end
return output:concat()
end
local function print_result(result)
local output = require "Module:array"()
for k, v in sorted_pairs(result) do
output:insert((as_and_sn_codes[k] or k) .. ": " .. v)
end
return output:concat(", ")
end
function tests:test_sn()
local examples = {
{ { sn = 4, ["sncj+"] = 3 }, { t = 4, k = 4, c = 3, j = 3 } },
}
self:iterate(
examples,
function (self, parameters, expected)
mw.logObject(parameters, "parameters")
mw.logObject(expected, "expected")
self:equals(print_parameters(parameters), print_result(expected), print_result({}))
end)
end
return tests