Difference between revisions of "Module:Language/testcases"
Jump to navigation
Jump to search
blackwiki>Erutuon (language tag) |
blackwiki>Erutuon (added iterate method to Module:UnitTests) |
||
| Line 2: | Line 2: | ||
local p = require 'Module:UnitTests' | local p = require 'Module:UnitTests' | ||
local m_Language = require 'Module:Language' | local m_Language = require 'Module:Language' | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
local function tag(word, languageCode) | local function tag(word, languageCode) | ||
Revision as of 03:47, 30 June 2018
Documentation for this module may be created at Module:Language/testcases/doc
-- Example Unit tests for [[Module:Bananas]]. Click talk page to run tests.
local p = require 'Module:UnitTests'
local m_Language = require 'Module:Language'
local function tag(word, languageCode)
return '<span lang="' .. languageCode .. '">' .. word .. '</span>'
end
local decompose = mw.ustring.toNFD
function p:check_makeEntryName(languageCode, word, expected)
self:equals(
tag(word, languageCode),
decompose(m_Language.makeEntryName(word, languageCode)),
decompose(expected),
{ display = function (word) return tag(word, languageCode) end })
end
p['test makeEntryName'] = function (self)
local examples = {
{ "ar", "العَرَبِيَّة", "العربية" },
{ "grc", "δημοκρᾰτῐ́ᾱ", "δημοκρατία" },
{ "ha", "àzàhàr̃iyyā̀", "azahariyya" },
{ "la", "coëō", "coeo" },
{ "nci", "Quetzalcōātl", "Quetzalcoatl" },
{ "ru", "ру́сский язы́к", "русский язык" },
{ "sh", "ćá", "ća" }, -- fake word with c-acute and tonal acute; add a real word if you know one
}
self:iterate(examples, "check_makeEntryName")
end
return p