local tests = require("Module:UnitTests")
local m_utils = require("Module:grc-utilities")
local compose = mw.ustring.toNFC
local tag = m_utils.tag
function tests:checkStandardDiacritics(example, expected)
self:equals(
tag(example),
compose(m_utils.standardDiacritics(example)),
compose(expected),
{ display = tag }
)
end
function tests:testStandardDiacritics()
local examples = {
{ "ἄ˘κρος", "ἄ̆κρος" },
}
tests:iterate(examples, "checkStandardDiacritics")
end
function tests:checkReorderDiacritics(example, expected)
self:equals(
tag(example),
compose(m_utils.reorderDiacritics(example)),
compose(expected),
{ display = tag }
)
end
function tests:testReorderDiacritics()
local examples = {
{ "ά̓̆νερ", "ᾰ̓́νερ" },
{ "ᾰ̓́̄", "ᾱ̆̓́" },
{ "ά̓̆̄", "ᾱ̆̓́" },
{ "ά̓̄̆", "ᾱ̆̓́" },
}
tests:iterate(examples, "checkReorderDiacritics")
end
local function displayFindAmbig(word)
local vowel_list = m_utils.findAmbig(word, true)
return compose(table.concat(vowel_list, ", "))
end
function tests:checkFindAmbig(example, expected)
self:equals(
tag(example),
displayFindAmbig(example),
expected,
{ display = tag }
)
end
function tests:testFindAmbig()
local examples = {
{ "Διονύσια", "ι, υ, ι, α" },
{ "πᾶς", "" },
{ "οἵᾳ", "" },
{ "μίᾰ", "ι" },
{ "ἐᾱ́ν", "" },
}
tests:iterate(examples, "checkFindAmbig")
end
local function displayTokenization(example, isNoun)
return table.concat(m_utils.tokenize(example, isNoun), ", ")
end
function tests:checkTokenize(example, expected, isNoun)
self:equals(
tag(example) .. (isNoun and " (noun)" or ""),
compose(displayTokenization(example, isNoun)),
compose(expected),
{ display = tag }
)
end
function tests:testTokenize()
local examples = {
{ "Διί", "Δ, ι, ί" },
{ "ιυ", "ι, υ" },
{ "υυ", "υ, υ" },
{ "υι", "υι" },
{ "γᾰλεοῦ", "γ, ᾰ, λ, ε, οῦ" },
{ "Λευίς", "Λ, ευ, ί, ς" },
{ "ἀληθέι", "ἀ, λ, η, θ, έ, ι" },
{ "πόλεως", "π, ό, λ, ε, ω, ς", true },
{ "πόλεων", "π, ό, λ, ε, ω, ν", true },
{ "οἷαι", "οἷ, αι" },
{ "ΟἿΑΙ", "ΟἿ, ΑΙ" },
{ "Αἰσχύλος", "Αἰ, σ, χ, ύ, λ, ο, ς" },
{ "ἀναῡ̈τέω", "ἀ, ν, α, ῡ̈, τ, έ, ω"},
{ "τούτῳ", "τ, ού, τ, ῳ" },
}
tests:iterate(examples, "checkTokenize")
end
function tests:checkPronunciationOrder(example, expected)
self:equals(
tag(example),
compose(m_utils.pronunciationOrder(example)),
compose(expected),
{ display = tag }
)
end
function tests:testPronunciationOrder()
local examples = {
{ "ἐᾱ́ν", "ἐά¯ν" },
{ "γᾰ́ρ", "γά˘ρ" },
{ "ᾰ̓λλᾰ́", "ἀ˘λλά˘" },
}
tests:iterate(examples, "checkPronunciationOrder")
end
return tests