local tests = require("Module:UnitTests")
local m_IPA = require("Module:lt-pron")
local function tag_IPA(IPA)
return '<span class="IPA">' .. IPA .. '</span>'
end
function tests:check_IPA(term, func, expected, comment)
self:equals(
m_IPA.link(term),
tag_IPA(mw.ustring.toNFC(func(term))),
tag_IPA(expected),
{ comment = comment, show_difference = true }
)
end
function tests:test_pron()
local examples = {
{ "stovė́ti", "stoːˈʋʲeː.tʲɪ", "" },
{ "galià", "ɡɐˈlʲɛ", "" },
{ "gàlia", "ˈɡɐ.lʲɛ", "" },
{ "apniū̃kti", "ɐpʲˈnʲuːk.tʲɪ", "" },
{ "pažìnti", "pɐˈʑɪnʲ.tʲɪ", "" },
{ "tamsùs", "tɐmˈsʊs", "" },
{ "abúojas", "ɐˈbûə.jɐs", "" },
{ "kóšė", "ˈkôː.ɕeː", ""},
{ "kõšė", "ˈkoː.ɕeː", ""},
{ "prie", "pʲrʲiə", ""},
{ "nórs", "ˈnôːrs", ""},
{ "gyvẽnimas", "ɡʲiːˈʋʲɛː.nʲɪ.mɐs", ""},
{ "kauburỹs", "kɐʊ̯ˑ.bʊˈrʲiːs", ""},
}
--[[ Copy the following to add more examples:
{ "", "", "" },
]]
for _, example in ipairs(examples) do
local term, expected, comment = unpack(example)
self:check_IPA(term, m_IPA.toIPA, expected, comment)
end
end
function tests:test_respell()
local examples = {
{ "pãieškos", "pãjieškos", "" },
{ "ievà", "jievà", "" },
{ "diẽmedis", "dʲiẽmʲedʲis", "" },
{ "apkeliáujanti", "apʲkʲelʲiáujanʲtʲi", "" },
{ "apniū̃kti", "apʲnʲū̃ktʲi", "" },
{ "abchãzą", "abçãzą", "" },
{ "biŏlŏ̀gija", "bʲijɔlɔ̀gʲija", "" },
}
--[[ Copy the following to add more examples:
{ "", "", "" },
]]
for _, example in ipairs(examples) do
local term, expected, comment = unpack(example)
self:check_IPA(term, m_IPA.respell, expected, comment)
end
end
return tests