local tests = require("Module:UnitTests")
local m_IPA = require("Module:User:OblivionKhorasan/pa-IPA-test")
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
local options = { display = tag_IPA, show_difference = true }
function tests:check_output_fa(term, romanisation, expected)
self:equals(
{link(term), romanisation},
m_IPA.fa_IPA(romanisation),
expected,
options
)
end
function tests:check_output_fa_cls(term, romanisation, expected)
self:equals(
{link(term), romanisation},
m_IPA.fa_cls_IPA(romanisation),
expected,
options
)
end
function tests:check_output_tg(term, romanisation, expected)
self:equals(
{link_tg(term), romanisation},
m_IPA.tg_IPA(romanisation),
expected,
options
)
end
function tests:check_output_prs(term, romanisation, expected)
self:equals(
{link(term), romanisation},
m_IPA.prs_IPA(romanisation),
expected,
options
)
end
function tests:test_classical_persian()
examples = {
{ "خوش", "xwś", "xʊʃ"},
{ "جھانجر", "`jHāṉjHar", "ˈd͡ʒʱãːn̠.d͡ʒəɾᵊ"},
{ "ساوݨ", "`sāvaN", "ˈsaː.ʋəɳᵊ"},
{ "مٹیار", "muTī`ār", "mʊ.ʈi.ˈjaːɾᵊ"},
{ "لیا", "`leā", "ˈleː.aː"},
{ "لیا", "le`ā", "le.ˈaː"},
{ "کڑوا", "`kaRvā", "ˈkəɽᵊ.ʋaː"},
{ "ملاوݨا", "milāvNā", "ˈmɪ.laːʋᵊ.ɳaː"},
}
--[[ Copy the following to add more examples:
{ "", "", ""},
]]
tests:iterate(examples, "check_output_fa_cls")
end
function tests:test_dari_persian()
examples = {
{ "خوش", "xwaš", "xʊʃ"},
{ "خواب", "xwāb", "xɑːb"},
{ "ابرنواختر", "abar-naw-ax`tar", "ʔä.bäɾ.näw.ʔäx.t̪ʰǽɾ"},
{ "ابراهیم", "ibrā`hīm", "ʔɪb.ɾɑː.ɦíːm"},
{ "امام", "i`mām", "ʔɪ.mɑ́ːm"},
{ "پیشوا", "pēš`vā", "pʰeːʃ.wɑ́ː"},
{ "نو", "naw", "näw"},
{ "مستعمره", "musta'ma`ra", "mʊs.t̪ʰäʔ.mä.ɾǽ"},
{ "آزاد", "ā`zād", "ʔɑː.zɑ́ːd̪"},
{ "قول", "qawl", "qäwl"},
{ "دولت", "dawlat", "d̪äw.lät̪"},
{ "آخور", "āxwar", "ʔɑː.xʊɾ"},
{ "لغو", "lağw", "läɣw"},
{ "گور", "gawr", "ɡäwɾ"},
{ "معتدل", "mu'tadil", "mo̞ʔ.t̪ʰä.d̪ɪl"},
{ "خوی", "xway", "xʊj"},
{ "خوید", "xwēd", "xeːd̪"},
}
--[[ Copy the following to add more examples:
{ "", "", ""},
]]
tests:iterate(examples, "check_output_prs")
end
function tests:test_iranian_persian()
examples = {
{ "خوش", "xwaš", "xoʃ"},
{ "خواب", "xwāb", "xɒːb̥"},
{ "ابرنواختر", "abar.naw.ax.`tar", "ʔæ.bæɹ.now.ʔæx.t̪ʰǽɹ"},
{ "ابراهیم", "ibrā`hīm", "ʔeb.ɹɒː.ɦíːm"},
{ "امام", "i`mām", "ʔe.mɒ́ːm"},
{ "پیشوا", "pēš`vā", "pʰiːʃ.vɒ́ː"},
{ "نو", "naw", "now"},
{ "مستعمره", "musta'ma`ra", "mos.t̪ʰæʔ.mæ.ɹé"},
{ "آزاد", "ā`zād", "ʔɒː.zɒ́ːd̪̥"},
{ "قول", "qawl", "qowl̥"},
{ "دولت", "dawlat", "d̪ow.læt̪"},
{ "آخور", "āxwar", "ʔɒː.xoɹ"},
{ "لغو", "lağw", "læɢv"},
{ "گور", "gawr", "ɡ̥owɹ"},
{ "معتدل", "mu'tadil", "moʔ.t̪ʰæ.d̪el̥"},
{ "خوی", "xway", "xoj"},
{ "خوید", "xwēd", "xiːd̪̥"},
{ "خودرو", "xwadraw", "xod̪.ɹow"},
{ "جو", "jaw", "d͡ʒow"},
{ "گوهر", "gaw`har", "ɡ̥ow.hǽɹ"},
{ "غلو", "ğuluw(w)", "qo.lov(v)"},
{ "پهلو", "pah`law", "pʰæɦ.lów"},
{ "کتاب", "ki`tāb", "kʰʲe.t̪ʰɒ́ːb̥"},
{ "مگر", "`magar", "mǽ.ɡʲæɹ"},
}
--[[ Copy the following to add more examples:
{ "", "", ""},
]]
tests:iterate(examples, "check_output_fa")
end
function tests:test_tajik()
examples = {
{ "хуш", "xwaš", "χuʃ"},
{ "хоб", "xwāb", "χɔb"},
{ "абарнавахтар", "abarnawax`tar", "abaɾnavaχˈtaɾ"},
{ "Иброҳим", "ibrā`hīm", "ibɾɔˈhim"},
{ "имом", "i`mām", "iˈmɔm"},
{ "пешво", "pēš`vā", "peʃˈvɔ"},
{ "нав", "naw", "nav"},
{ "мустаъмара", "musta'ma`ra", "mustaʔmaˈɾa"},
{ "фoтеҳ", "fā`tih", "fɔˈteh"},
{ "диҳад", "di`had", "diˈhad"},
{ "фасеҳ", "fa`sīh", "faˈseh"},
{ "васеъ", "va`sī\'", "vaˈseʔ"},
{ "охур", "āxwar", "ɔχuɾ"},
{ "лағв", "lağw", "laʁv"},
{ "биҳишт", "bihišt", "bihiʃt"},
{ "мӯътадил", "mu'tadil", "mɵʔtadil"},
{ "хуй", "xway", "χuj"},
{ "хед", "xwēd", "χed"},
}
--[[ Copy the following to add more examples:
{ "", "", ""},
]]
tests:iterate(examples, "check_output_tg")
end
return tests