Jump to content

Module:User:Erutuon/grc/testcases

From Wiktionary, the free dictionary

3 of 18 tests failed. (refresh)

TextExpectedActual
test_get_participle_information:
Passedπῑ́πτωνπῑ́πτουσᾰ, πῖπτον (1&3, πῑ́πτω)πῑ́πτουσᾰ, πῖπτον (1&3, πῑ́πτω)
Passedλᾰβώνλᾰβοῦσᾰ, λᾰβόν (1&3, ?)λᾰβοῦσᾰ, λᾰβόν (1&3, ?)
Passedτῑμῶντῑμῶσᾰ, τῑμῶν (1&3, τῑμᾰ́ω)τῑμῶσᾰ, τῑμῶν (1&3, τῑμᾰ́ω)
Passedποιῶνποιοῦσᾰ, ποιοῦν (1&3, ποιέω)ποιοῦσᾰ, ποιοῦν (1&3, ποιέω)
Passedδηλῶνδηλοῦσᾰ, δηλοῦν (1&3, δηλόω)δηλοῦσᾰ, δηλοῦν (1&3, δηλόω)
Passedεἰδώςεἰδυῖᾰ, εἰδός (1&3, ?)εἰδυῖᾰ, εἰδός (1&3, ?)
Passedλεγόμενοςλεγομένη, λεγόμενον (1&2, λέγω)λεγομένη, λεγόμενον (1&2, λέγω)
Passedθείςθεῖσᾰ, θέν (1&3, ?)θεῖσᾰ, θέν (1&3, ?)
Passedᾰ̓ξῐώσᾱςᾰ̓ξῐώσᾱσᾰ, ᾰ̓ξῐῶσᾰν (1&3, ?)ᾰ̓ξῐώσᾱσᾰ, ᾰ̓ξῐῶσᾰν (1&3, ?)
TextExpectedActual
test_tokenize:
PassedΛεωνίδης (noun)Λ, ε, ω, ν, ί, δ, η, ςΛ, ε, ω, ν, ί, δ, η, ς
Passedἀληθέιἀ, λ, η, θ, έ, ιἀ, λ, η, θ, έ, ι
Failedπόλεως (noun)π, ό, λ, εω, ςπ, ό, λ, ε, ω, ς
Failedπόλεων (noun)π, ό, λ, εω, νπ, ό, λ, ε, ω, ν
Passedοἷαιοἷ, αιοἷ, αι
PassedΟἿΑΙΟἿ, ΑΙΟἿ, ΑΙ
FailedΑἰσχύλοςΑἰ, σχ, ύ, λ, ο, ςΑἰ, σ, χ, ύ, λ, ο, ς
Passedἀναῡ̈τέωἀ, ν, α, ῡ̈, τ, έ, ωἀ, ν, α, ῡ̈, τ, έ, ω
Passedτούτῳτ, ού, τ, ῳτ, ού, τ, ῳ

local tests = require("Module:UnitTests")

local m_grc = require("Module:User:Erutuon/grc")
local tokenize = m_grc.tokenize
local get_participle_information = m_grc.get_participle_information
local tag = require("Module:grc-utilities").tag
local compose = mw.ustring.toNFC

local function displayTokenization(example, isNoun)
	return table.concat(tokenize(example, isNoun), ", ")
end

function tests:check_tokenize(example, expected, isNoun)
	self:equals(
		tag(example) .. (isNoun and " (noun)" or ""),
		compose(displayTokenization(example, isNoun)),
		compose(expected),
		{ display = tag, show_difference = true }
	)
end

local function show_participle_information(decl, feminine, neuter, lemma)
	decl, feminine, neuter, lemma = decl or "?", feminine or "?", neuter or "?", lemma or "?"
	return mw.ustring.toNFC(tag(feminine) .. ", " .. tag(neuter) .. " (" .. decl
		.. ", " .. tag(lemma) .. ")")
end

local options = { show_difference = true }
function tests:check_get_participle_information(example, contraction_vowel, expected)
	self:equals(
		tag(example),
		show_participle_information(get_participle_information(example, contraction_vowel)),
		show_participle_information(unpack(expected)),
		options)
end

function tests:test_get_participle_information()
	local examples = {
		{ "πῑ́πτων",    nil, { "1&3", "πῑ́πτουσᾰ", "πῖπτον", "πῑ́πτω" } },
		{ "λᾰβών",     nil, { "1&3", "λᾰβοῦσᾰ",  "λᾰβόν", nil } },
		{ "τῑμῶν",     "a", { "1&3", "τῑμῶσᾰ",   "τῑμῶν", "τῑμᾰ́ω" } },
		{ "ποιῶν",     "e", { "1&3", "ποιοῦσᾰ",  "ποιοῦν", "ποιέω" } },
		{ "δηλῶν",     "o", { "1&3", "δηλοῦσᾰ",  "δηλοῦν", "δηλόω" } },
		{ "εἰδώς",     nil, { "1&3", "εἰδυῖᾰ",   "εἰδός", nil } },
		{ "λεγόμενος", nil, { "1&2", "λεγομένη", "λεγόμενον", "λέγω" } },
		{ "θείς",      nil, { "1&3", "θεῖσᾰ",    "θέν", nil } },
		{ "ᾰ̓ξῐώσᾱς",   nil, { "1&3", "ᾰ̓ξῐώσᾱσᾰ", "ᾰ̓ξῐῶσᾰν", nil } },
	}
	
	self:iterate(examples, "check_get_participle_information")
end

function tests:test_tokenize()
	local examples = {
		{ "Λεωνίδης", "Λ, ε, ω, ν, ί, δ, η, ς", true },
		{ "ἀληθέι", "ἀ, λ, η, θ, έ, ι" },
		{ "πόλεως", "π, ό, λ, εω, ς", true },
		{ "πόλεων", "π, ό, λ, εω, ν", true },
		{ "οἷαι", "οἷ, αι" },
		{ "ΟἿΑΙ", "ΟἿ, ΑΙ" },
		{ "Αἰσχύλος", "Αἰ, σχ, ύ, λ, ο, ς" },
		{ "ἀναῡ̈τέω", "ἀ, ν, α, ῡ̈, τ, έ, ω"},
		{ "τούτῳ", "τ, ού, τ, ῳ" },
	}
	
	self:iterate(examples, "check_tokenize")
end

return tests