local tests = require("Module:UnitTests")
local m_IPA = require("Module:fa-IPA/sandbox")
local sc_fa = require("Module:scripts").getByCode("fa-Arab")
local sc_tg = require("Module:scripts").getByCode("Cyrl")
local lang_fa = require("Module:languages").getByCode("fa")
local lang_tg = require("Module:languages").getByCode("tg")
function link(term)
return require("Module:links").full_link {
term = term,
lang = lang_fa,
sc = sc_fa
}
end
function link_tg(term)
return require("Module:links").full_link {
term = term,
lang = lang_tg,
sc = sc_tg
}
end
local function tag_IPA(IPA)
return '<span class="IPA">' .. IPA .. '</span>'
end
function tests:check_output_fa(term, romanisation, expected)
self:equals(
{link(term), romanisation},
tag_IPA(m_IPA.fa_IPA(romanisation)),
tag_IPA(expected)
)
end
function tests:check_output_prs_kbl(term, romanisation, expected)
self:equals(
{link(term), romanisation},
tag_IPA(m_IPA.prs_kbl_IPA(romanisation)),
tag_IPA(expected)
)
end
function tests:check_output_prs_haz(term, romanisation, expected)
self:equals(
{link(term), romanisation},
tag_IPA(m_IPA.prs_haz_IPA(romanisation)),
tag_IPA(expected)
)
end
function tests:check_output_fa_cls(term, romanisation, expected)
self:equals(
{link(term), romanisation},
tag_IPA(m_IPA.fa_cls_IPA(romanisation)),
tag_IPA(expected)
)
end
function tests:check_output_tg(term, romanisation, expected)
self:equals(
{link(term), romanisation},
tag_IPA(m_IPA.tg_IPA(romanisation)),
tag_IPA(expected)
)
end
function tests:check_output_prs(term, romanisation, expected)
self:equals(
{link(term), romanisation},
tag_IPA(m_IPA.prs_IPA(romanisation)),
tag_IPA(expected)
)
end
function tests:test_kbl_persian()
examples = {
{ "خوش", "xwaš", "χʊʃ"},
{ "خواب", "xwāb", "χʌːb"},
{ "ابرنواختر", "abarnaw.ax`tar", "ʔä.bäɾ.näw.äχ.t̪ʰǽɾ"},
{ "ابراهیم", "ibrā`hīm", "ʔɪb.ɾʌː.jíːm"},
{ "پیشوا", "pēš`vā", "pʰeːʃ.wʌ́ː"},
{ "مستعمره", "musta'ma`ra", "mʊs.t̪ʰʌː.mä.ɾǽ"},
{ "معتدل", "mu'tadil", "moː.t̪ʰä.d̪ɪl"},
{ "محمد", "muhammad", "mʊ.wäm.mäd̪"},
}
--[[ Copy the following to add more examples:
{ "", "", ""},
]]
tests:iterate(examples, "check_output_prs_kbl")
end
function tests:test_haz_persian()
examples = {
{ "خواب", "xwāb", "χɔːb̥"},
{ "ابرنواختر", "abarnaw.ax`tar", "ʔä.bäɾ.näw.äχ.t̪ʰǽɾ"},
{ "ابراهیم", "ibrā`hīm", "ʔib.ɾɔː.jíːm"},
{ "امام", "i`mām", "ʔi.mɔ́ːm"},
{ "پیشوا", "pēš`vā", "pʰeːʃ.wɔ́ː"},
{ "مستعمره", "musta'ma`ra", "mus.t̪ʰɔː.mä.ɾǽ"},
{ "آزاد", "ā`zād", "ʔɔː.zɔ́ːd̪̥"},
{ "معتدل", "mu'tadil", "mʊː.t̪ʰä.d̪il̥"},
{ "خوید", "xwēd", "χeːd̪̥"},
{ "محمد", "muhammad", "mu.wäm.mäd̪̥"},
{ "لیکن", "lēkin", "li.kʰin"},
{ "دندان", "dandān", "d̪än̪.d̪ɔːn"},
{ "بند", "band", "bän̪d̪̥"},
{ "کٹه", "kaTa", "kʰä.ʈä"},
}
--[[ Copy the following to add more examples:
{ "", "", ""},
]]
tests:iterate(examples, "check_output_prs_haz")
end
return tests