Module:grc-utilities/testcases

From Wiktionary, the free dictionary
Jump to navigation Jump to search

All tests passed. (refresh)

TextExpectedActualDiffers at
testFindAmbig:
PassedΔιονύσιαι, υ, ι, αι, υ, ι, α
Passedπᾶς
Passedοἵᾳ
Passedμίᾰιι
Passedἐᾱ́ν
TextExpectedActualDiffers at
testPronunciationOrder:
Passedἐᾱ́νἐά¯νἐά¯ν
Passedγᾰ́ργά˘ργά˘ρ
Passedᾰ̓λλᾰ́ἀ˘λλά˘ἀ˘λλά˘
TextExpectedActualDiffers at
testReorderDiacritics:
Passedά̓̆νερᾰ̓́νερᾰ̓́νερ
Passedᾰ̓́̄ᾱ̆̓́ᾱ̆̓́
Passedά̓̆̄ᾱ̆̓́ᾱ̆̓́
Passedά̓̄̆ᾱ̆̓́ᾱ̆̓́
TextExpectedActualDiffers at
testStandardDiacritics:
Passedἄ˘κροςἄ̆κροςἄ̆κρος
TextExpectedActualDiffers at
testTokenize:
PassedΔιίΔ, ι, ίΔ, ι, ί
Passedιυι, υι, υ
Passedυυυ, υυ, υ
Passedυιυιυι
Passedγᾰλεοῦγ, ᾰ, λ, ε, οῦγ, ᾰ, λ, ε, οῦ
PassedΛευίςΛ, ευ, ί, ςΛ, ευ, ί, ς
Passedἀληθέιἀ, λ, η, θ, έ, ιἀ, λ, η, θ, έ, ι
Passedπόλεως (noun)π, ό, λ, ε, ω, ςπ, ό, λ, ε, ω, ς
Passedπόλεων (noun)π, ό, λ, ε, ω, νπ, ό, λ, ε, ω, ν
Passedοἷαιοἷ, αιοἷ, αι
PassedΟἿΑΙΟἿ, ΑΙΟἿ, ΑΙ
PassedΑἰσχύλοςΑἰ, σ, χ, ύ, λ, ο, ςΑἰ, σ, χ, ύ, λ, ο, ς
Passedἀναῡ̈τέωἀ, ν, α, ῡ̈, τ, έ, ωἀ, ν, α, ῡ̈, τ, έ, ω
Passedτούτῳτ, ού, τ, ῳτ, ού, τ, ῳ

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