Module:Sandbox/Erutuon/testcases
Appearance
![]() | This is the test cases page for the module Module:Sandbox/Erutuon. Results of the test cases. |
local p = require "Module:UnitTests"
local parse_IETF = require "Module:Sandbox/Erutuon".parse_IETF
function p:test_parse_IETF()
local examples = {
{ "ru", { language = "ru" } },
{ "ru-Latn", { language = "ru", script = "Latn" } },
{ "ine-x-proto", { language = "ine", private_use = "x-proto" } },
{ "ine-!!!", { error = "invalid characters", invalid = "ine-!!!" } },
{ "Latn", { error = "no language subtag", script = "Latn", invalid = "Latn" } },
{ "ru-blahblahblah", { language = "ru", error = "invalid subtag", invalid = "blahblahblah" } },
{ "ru-Latn-blahblahblah", { language = "ru", script = "Latn", error = "invalid subtag", invalid = "blahblahblah" } },
{ "ru-x-blahblahblah", { language = "ru", error = "length of private-use subtag out of range", invalid = "x-blahblahblah" } },
{ "ru-x", { language = "ru", error = "empty private-use subtag", invalid = "x" } },
{ "", nil },
-- { mw.log, nil },
-- { nil, nil },
}
self:iterate(
examples,
function (self, IETF_code, expected)
self:equals_deep(IETF_code, parse_IETF(IETF_code), expected)
end)
end
return p