Module:User:Erutuon/scripts/testcases
Appearance
- The following documentation is located at Module:User:Erutuon/scripts/testcases/documentation. [edit]
- Useful links: root page • root page’s subpages • links • transclusions • tested module • sandbox
Lua error in Module:User:Erutuon/scripts at line 181: attempt to call field 'memoize' (a nil value)
local tests = require("Module:UnitTests")
local find_best_script = require "Module:User:Erutuon/scripts".find_best_script
local tag_text = require "Module:script utilities".tag_text
local get_lang_by_code = require("Module:languages").getByCode
local get_script_by_code = require "Module:scripts".getByCode
local function tag(text, lang, scCode)
return tag_text(text, lang, get_script_by_code(scCode))
end
function tests:check_find_best_script(example, lang_code, expected)
local lang = get_lang_by_code(lang_code)
self:equals(tag(example, lang, expected) .. " (" .. lang:getCanonicalName() .. ")",
find_best_script(example, lang_code),
expected)
end
function tests:test_find_best_script()
local examples = {
{ "word", "en", "Latn" },
{ "большо́й", "ru", "Cyrl" },
{ "ругала се шерпа лонцу широка му уста", "sh", "Cyrl" },
"Scripts with overlapping characters",
{ "my", "en", "Latn" },
{ "my", "egy", "Latnx" },
{ "Русь", "orv", "Cyrs" },
{ "Русь", "ru", "Cyrl" },
{ "λόγος", "grc", "polytonic" },
{ "λόγος", "el", "Grek" },
"Scripts using the exact same characters as another script",
{ "anaasází", "nv", "nv-Latn" },
{ "العربية", "ar", "Arab" },
{ "عرب", "fa", "fa-Arab" },
"Scripts consisting of two or more other scripts",
{ "ああ言えばこう言う", "ja", "Jpan" },
{ "アイリッシュ海", "ja", "Jpan" },
"Scripts sometimes containing characters of another script",
{ "ABC順", "ja", "Jpan" },
{ "OX로", "ko", "Kore" },
"Extraneous characters",
{ "<<<<a>>>>", "en", "Latn" },
}
tests:iterate(examples, "check_find_best_script")
end
return tests