Content deleted Content added
m two script tags |
|||
(9 intermediate revisions by the same user not shown) | |||
Line 6:
language = function (subtags, key)
if not subtags[key] then return nil end
return ("%s: <code>%s</code>"):format(key, subtags[key] or '')
end,
variant = function (subtags, key)
if not subtags[key] then return nil end
return ("%s: <code>%s</code>"):format(
key,
type(subtags[key]) == "table" and table.concat(subtags[key], ", ")
Line 20:
end
return ("error: %s at
:format(subtags.error, subtags.invalid or "???")
end,
Line 44:
return result:concat("; ")
end
Line 64 ⟶ 50:
{ "ru", { language = "ru" } },
{ "ru-Latn", { language = "ru", script = "Latn" } },
{ "
{ "ru
{ "zh-Latn-pinyin", { language = "zh", script = "Latn", variant = "pinyin" } },
{ "sl-rozaj-biske", { language = "sl", variant = { "rozaj", "biske" } } },
Line 74 ⟶ 59:
-- Could be used to indicate the PIE transcription system used by Pokorny?
{ "ine-x-proto-pokorny", { language = "ine", private_use = { "proto", "pokorny" } } },
{ "x-fake-private-use", { private_use = { "fake", "private", "use" } } },
"errors",
{ "ine-!!!", { error = "invalid characters", invalid = "!!!" } },
{ "pâté", { error = "invalid characters", invalid = "pâté" } },
{ "Latn", { error = "no language subtag
{ "ru-Latn-Cyrl", { language = "ru", script = "Latn", error = "invalid subtag", invalid = "Cyrl" } },
{ "blahblahblah", { error = "
{ "ru-blahblahblah", { language = "ru", error = "invalid subtag", invalid = "blahblahblah" } },
{ "ru-Latn-blahblahblah",
Line 94 ⟶ 72:
{ 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" } },
{ "blahblah-Latn", { error = "no language subtag", invalid = "blahblah-Latn" } },
{ "", nil },
-- { mw.log, nil },
-- { nil, nil },
}
local index = fun.indexOf("errors", examples)
table.insert(examples, index, "case-insensitivity")
for i = 1, index - 1 do -- Insert testcases for capitalized versions of the valid tags.
local upper_example = mw.clone(examples[i])
upper_example[1] = upper_example[1]:upper()
table.insert(examples, index + i, upper_example)
end
self:iterate(
Line 103 ⟶ 90:
function (self, IETF_code, expected)
self:equals(
('<code style="white-space: nowrap;">%s</code>'):format(IETF_code),
show_parsed_subtags(parse_IETF(IETF_code)),
show_parsed_subtags(expected))
Line 110 ⟶ 97:
-- Change function names into more readable headers for the testcases tables.
for k, v in require "Module:
if type(k) == "string" then
local new_k = k:gsub("^test_(.+)$", "testcases for <code>%1</code>")
|