Difference between revisions of "Module:Language/scripts/testcases"
< Module:Language | scripts
Jump to navigation
Jump to search
blackwiki>Erutuon (+) |
blackwiki>Erutuon (use mapIter from Module:fun, iterate method from Module:UnitTests) |
||
| Line 6: | Line 6: | ||
local sortedPairs = require("Module:table").sortedPairs | local sortedPairs = require("Module:table").sortedPairs | ||
| − | local | + | local mapIter = require("Module:fun").mapIter |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
local function showScripts(text) | local function showScripts(text) | ||
local scripts = countScripts(text) | local scripts = countScripts(text) | ||
return table.concat( | return table.concat( | ||
| − | + | mapIter(function(v, k) | |
return k .. " (" .. v .. ")" | return k .. " (" .. v .. ")" | ||
end, | end, | ||
| − | countScripts(text)), | + | sortedPairs(countScripts(text))), |
", ") | ", ") | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
end | end | ||
Revision as of 03:44, 30 June 2018
Documentation for this module may be created at Module:Language/scripts/testcases/doc
local p = require('Module:UnitTests')
local scripts = require("Module:Language/scripts")
local countScripts = scripts.countScripts
local getScript = scripts.getScript
local sortedPairs = require("Module:table").sortedPairs
local mapIter = require("Module:fun").mapIter
local function showScripts(text)
local scripts = countScripts(text)
return table.concat(
mapIter(function(v, k)
return k .. " (" .. v .. ")"
end,
sortedPairs(countScripts(text))),
", ")
end
function p:checkCountScripts(example, expected)
self:equals(example, showScripts(example), expected)
end
function p:checkGetScript(example, expected)
self:equals(example, getScript(example), expected)
end
p["testcases for countScripts"] = function (self)
local examples = {
{
"'''Ста́нция Восто́к'''",
"Cyrl (13), Zinh (2), Zyyy (7)"
},
{ "Σωκράτης", "Grek (8)" },
{ "中华人民共和国", "Hani (7)" },
{ "অবনী বাড়ি আছো ''Ôboni Baŗi Achho''", "Beng (12), Latn (14), Zyyy (9)" }, -- from previous revision of [[Abani Bari Achho]]
}
self:iterate(examples, "checkCountScripts")
end
p["testcases for getScript"] = function (self)
local examples = {
{ "'''Ста́нция Восто́к'''", "Cyrl" },
{ mw.ustring.toNFD "Ἑλλήσποντος", "Grek" }, -- decompose to get version with combining diacritics
}
self:iterate(examples, "checkGetScript")
end
return p