Module:grc-form of/testcases

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

All tests passed. (refresh)

TextExpectedActualComments
test_processing:
Passedp, nom, masc (adjective){"masculine", "nominative", "plural"}{"masculine", "nominative", "plural"}
Passedplural, nominative, masculine (adjective){"masculine", "nominative", "plural"}{"masculine", "nominative", "plural"}
Passedplural, subjunctive (noun)"error""error"Module:grc-form_of:89: The category “mood” is not used by the part of speech “noun”.
Passedmasculine, feminine, plural (noun)"error""error"Module:grc-form_of:16: There were multiple labels belonging to the same category: “gender”: “masculine”, “feminine”.
Passed3, s, aor, subj, act (verb){"third person", "singular", "aorist", "subjunctive", "active"}{"third person", "singular", "aorist", "subjunctive", "active"}
Passedpres, inf, act (verb){"present", "active", "infinitive"}{"present", "active", "infinitive"}
Passed3, s, inf, act (verb)"error""error"Module:grc-form_of:89: The categories “number”, “person” are not used by the part of speech “infinitive”.
Passedpres, inf, act (varb)"error""error"Module:grc-form_of:78: The part of speech “varb” does not have a set of valid inflectional categories.
Passedm, nom, p, part, act (verb){"masculine", "nominative", "plural", "active", "participle"}{"masculine", "nominative", "plural", "active", "participle"}
Passedm, nom, p, part, subj, act (verb)"error""error"Module:grc-form_of:89: The category “mood” is not used by the part of speech “participle”.

local tests = require("Module:UnitTests")

local _process = require("Module:grc-form of").process

local error_messages = {}
local function process(...)
	local success, result = pcall(_process, ...)
	if success then
		return result
	else
		error_messages[...] = result
		return "error"
	end
end

local function display(labels, POS)
	return table.concat(labels, ", ") .. " (" .. POS .. ")"
end

function tests:check_processing(labels, POS, expected)
	local actual = process(labels, POS) -- so that error message is logged when equals_deep is called
	self:equals_deep(display(labels, POS), actual, expected, { comment = error_messages[labels] })
end

function tests:test_processing()
	local examples = {
		{ { "p", "nom", "masc" }, "adjective", { "masculine", "nominative", "plural" } },
		{ { "plural", "nominative", "masculine" }, "adjective", { "masculine", "nominative", "plural" } },
		{ { "plural", "subjunctive" }, "noun", "error" },
		{ { "masculine", "feminine", "plural" }, "noun", "error" },
		{ { "3", "s", "aor", "subj", "act" }, "verb", { "third person", "singular", "aorist", "subjunctive", "active" } },
		{ { "pres", "inf", "act" }, "verb", { "present", "active", "infinitive" } },
		{ { "3", "s", "inf", "act" }, "verb", "error" },
		{ { "pres", "inf", "act" }, "varb", "error" },
		{ { "m", "nom", "p", "part", "act" }, "verb", { "masculine", "nominative", "plural", "active", "participle" } },
		{ { "m", "nom", "p", "part", "subj", "act" }, "verb", "error" },
	}
	
	self:iterate(examples, "check_processing")
end

return tests