Module:grc-headword/testcases

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

8 of 13 tests failed. (refresh)

TextExpectedActual
test:
nouns
Passedδῆμος:
{{grc-noun|δήμου|m|second}}
{genders={"m"},
heads={"δῆμος"},
inflections={{"δήμου", label="genitive"}},
no_redundant_head_cat=true}
{genders={"m"},
heads={"δῆμος"},
inflections={{"δήμου", label="genitive"}},
no_redundant_head_cat=true}
Passedἵππος:
{{grc-noun|ῐ̔́ππος|ῐ̔́ππου|m|second}}
{genders={"m"},
heads={"ῐ̔́ππος"},
inflections={{"ῐ̔́ππου", label="genitive"}},
no_redundant_head_cat=false}
{genders={"m"},
heads={"ῐ̔́ππος"},
inflections={{"ῐ̔́ππου", label="genitive"}},
no_redundant_head_cat=false}
indeclinable nouns
PassedΓαβριήλ:
{{grc-proper noun|Γαβρῑήλ|m}}
{genders={"m"},
heads={"Γαβρῑήλ"},
inflections={{label="indeclinable"}},
no_redundant_head_cat=false}
{genders={"m"},
heads={"Γαβρῑήλ"},
inflections={{label="indeclinable"}},
no_redundant_head_cat=false}
PassedΓαβριήλ:
{{grc-proper noun|m}}
{genders={"m"},
heads={"Γαβριήλ"},
inflections={{label="indeclinable"}},
no_redundant_head_cat=true}
{genders={"m"},
heads={"Γαβριήλ"},
inflections={{label="indeclinable"}},
no_redundant_head_cat=true}
PassedΓαβριήλ:
{{grc-proper noun|g=m|head=Γαβρῑήλ}}
{genders={"m"},
heads={"Γαβρῑήλ"},
inflections={{label="indeclinable"}},
no_redundant_head_cat=false}
{genders={"m"},
heads={"Γαβρῑήλ"},
inflections={{label="indeclinable"}},
no_redundant_head_cat=false}
verbs
Failedἵστημι:
{{grc-verb|ῐ̔́στημῐ}}
{genders={},
heads={"ῐ̔́στημῐ"},
inflections={}}
{genders={},
heads={"ῐ̔́στημῐ"},
inflections={},
no_redundant_head_cat=false}
particles
Failedγε:
{{grc-particle|disc=1}}
{genders={},
heads={"γε"},
inflections={{label="discourse particle"}}}
{genders={},
heads={"γε"},
inflections={{label="discourse particle"}},
no_redundant_head_cat=true}
adjectives and participles
Failedσός:
{{grc-adj-1&2|σή|σόν}}
{genders={"m"},
heads={"σός"},
inflections={{"σή", label="feminine"}, {"σόν", label="neuter"}}}
{genders={"m"},
heads={"σός"},
inflections={{"σή", label="feminine"}, {"σόν", label="neuter"}},
no_redundant_head_cat=true}
Failedστάμενος:
{{grc-part-1&2|στᾰ́μενος|στᾰμένη|στᾰ́μενον}}
{genders={"m"},
heads={"στᾰ́μενος"},
inflections={{"στᾰμένη", label="feminine"}, {"στᾰ́μενον", label="neuter"}}}
{genders={"m"},
heads={"στᾰ́μενος"},
inflections={{"στᾰμένη", label="feminine"}, {"στᾰ́μενον", label="neuter"}},
no_redundant_head_cat=false}
Failedβαρύς:
{{grc-adj-1&3|βᾰρῠ́ς|βᾰρεῖᾰ|βᾰρῠ́}}
{genders={"m"},
heads={"βᾰρῠ́ς"},
inflections={{"βᾰρεῖᾰ", label="feminine"}, {"βᾰρῠ́", label="neuter"}}}
{genders={"m"},
heads={"βᾰρῠ́ς"},
inflections={{"βᾰρεῖᾰ", label="feminine"}, {"βᾰρῠ́", label="neuter"}},
no_redundant_head_cat=false}
Failedστάς:
{{grc-part-1&3|στᾱ́ς|στᾶσᾰ|στᾰ́ν}}
{genders={"m"},
heads={"στᾱ́ς"},
inflections={{"στᾶσᾰ", label="feminine"}, {"στᾰ́ν", label="neuter"}}}
{genders={"m"},
heads={"στᾱ́ς"},
inflections={{"στᾶσᾰ", label="feminine"}, {"στᾰ́ν", label="neuter"}},
no_redundant_head_cat=false}
Failedἄδικος:
{{grc-adj-2nd|ᾰ̓́δῐκος|ᾰ̓́δῐκον}}
{genders={"m", "f"},
heads={"ᾰ̓́δῐκος"},
inflections={{"ᾰ̓́δῐκον", label="neuter"}}}
{genders={"m", "f"},
heads={"ᾰ̓́δῐκος"},
inflections={{"ᾰ̓́δῐκον", label="neuter"}},
no_redundant_head_cat=false}
Failedὑγιής:
{{grc-adj-3rd|ῠ̔γῐής|ῠ̔γῐές}}
{genders={"m", "f"},
heads={"ῠ̔γῐής"},
inflections={{"ῠ̔γῐές", label="neuter"}}}
{genders={"m", "f"},
heads={"ῠ̔γῐής"},
inflections={{"ῠ̔γῐές", label="neuter"}},
no_redundant_head_cat=false}

local tests = require("Module:UnitTests")

-- arguments: parent_frame, frame, pagename?
local test_headword = require("Module:grc-headword").test

local show_template = require("Module:template link").format_link
local clone = require("Module:table").shallowcopy

-- For now the categories don't really need testing.
local to_be_removed = { "categories", "pos_category" }

local function remove_keys(t, keys)
	for _, key in ipairs(keys) do
		t[key] = nil
	end
	return t
end

local function tag_and_link(term)
	return '<span class="Polyt" lang="grc">[[' .. term .. '#Ancient Greek|' .. term .. ']]</span>'
end

local abbrevs = { adjectives = "adj", participles = "part" }
local function display(frame, parent_frame, pagename)
	parent_frame = clone(parent_frame)
	local name = ("grc-" .. (abbrevs[frame[1]] or frame[1]) .. (frame[2] and "-" .. frame[2] or "")):gsub("s$", "")
	return tag_and_link(pagename) .. ":<br>" .. show_template(name, parent_frame)
end

local options = {
	nowiki = true,
	display = function (text)
		return "<code>" .. text:gsub("&#(%d+);", string.char):gsub("(%a[%w_]*=%b{},) ", "%1<br>") .. "</code>"
	end,
}
function tests:check(frame, parent_frame, pagename, expected)
	local data = test_headword(frame, parent_frame, pagename)
	remove_keys(data, to_be_removed)
	self:equals_deep(display(frame, parent_frame, pagename),
		data, expected, options)
end

function tests:test()
	local examples = {
		"nouns",
		{
			{ "nouns" }, { "δήμου", "m", "second" }, "δῆμος",
			{genders={"m"}, heads={"δῆμος"}, inflections={{"δήμου", label="genitive"}}, no_redundant_head_cat=true}
		},
		{
			{ "nouns" }, { "ῐ̔́ππος", "ῐ̔́ππου", "m", "second" }, "ἵππος",
			{genders={"m"}, heads={"ῐ̔́ππος"}, inflections={{"ῐ̔́ππου", label="genitive"}}, no_redundant_head_cat=false}
		},
		"indeclinable nouns",
		{
			{ "proper nouns" }, { "Γαβρῑήλ", "m" }, "Γαβριήλ",
			{heads={"Γαβρῑήλ"}, genders={"m"}, inflections={{label="[[Appendix:Glossary#indeclinable|indeclinable]]"}}, no_redundant_head_cat=false}
		},
		{
			{ "proper nouns" }, { "m" }, "Γαβριήλ",
			{heads={"Γαβριήλ"}, genders={"m"}, inflections={{label="[[Appendix:Glossary#indeclinable|indeclinable]]"}}, no_redundant_head_cat=true}
		},
		{
			{ "proper nouns" }, { head = "Γαβρῑήλ", g = "m" }, "Γαβριήλ",
			{heads={"Γαβρῑήλ"}, genders={"m"}, inflections={{label="[[Appendix:Glossary#indeclinable|indeclinable]]"}}, no_redundant_head_cat=false}
		},
		"verbs",
		{
			{ "verbs" }, { "ῐ̔́στημῐ" }, "ἵστημι",
			{genders={}, heads={"ῐ̔́στημῐ"}, inflections={}}
		},
		"particles",
		{
			{ "particles" }, { disc = 1 }, "γε",
			{genders={}, heads={"γε"}, inflections={{label="discourse particle"}}}
		},
		"adjectives and participles",
		{
			{ "adjectives", "1&2" }, { "σή", "σόν" }, "σός",
			{genders={"m"}, heads={"σός"}, inflections={{"σή", label="feminine"}, {"σόν", label="neuter"}}}
		},
		{
			{ "participles", "1&2" }, { "στᾰ́μενος", "στᾰμένη", "στᾰ́μενον" }, "στάμενος",
			{genders={"m"}, heads={"στᾰ́μενος"}, inflections={{"στᾰμένη", label="feminine"}, {"στᾰ́μενον", label="neuter"}}}
		},
		{
			{ "adjectives", "1&3" }, { "βᾰρῠ́ς", "βᾰρεῖᾰ", "βᾰρῠ́" }, "βαρύς",
			{genders={"m"}, heads={"βᾰρῠ́ς"}, inflections={{"βᾰρεῖᾰ", label="feminine"}, {"βᾰρῠ́", label="neuter"}}}
		},
		{
			{ "participles", "1&3" }, { "στᾱ́ς", "στᾶσᾰ", "στᾰ́ν" }, "στάς",
			{genders={"m"}, heads={"στᾱ́ς"}, inflections={{"στᾶσᾰ", label="feminine"}, {"στᾰ́ν", label="neuter"}}}
		},
		{
			{ "adjectives", "2nd" }, { "ᾰ̓́δῐκος", "ᾰ̓́δῐκον" }, "ἄδικος",
			{genders={"m", "f"}, heads={"ᾰ̓́δῐκος"}, inflections={{"ᾰ̓́δῐκον", label="neuter"}}}
		},
		{
			{ "adjectives", "3rd" }, { "ῠ̔γῐής", "ῠ̔γῐές" }, "ὑγιής",
			{genders={"m", "f"}, heads={"ῠ̔γῐής"}, inflections={{"ῠ̔γῐές", label="neuter"}}}
		},
		--[[
		{
			{}, {}, "",
			{}
		},
		--]]
	}
	
	self:iterate(examples, "check")
end

return tests