Module:User:Benwing2/es-verb/testcases

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

1 of 0 tests failed. (refresh)

TextExpectedActual
test:
Script error during testing: Module:User:Benwing2/es-verb:2049: attempt to call field 'add_links' (a nil value)
stack traceback:
	[C]: in function 'add_links'
	Module:User:Benwing2/es-verb:2049: in function 'normalize_all_lemmas'
	Module:User:Benwing2/es-verb:3134: in function 'do_generate_forms'
	Module:User:Benwing2/es-verb/testcases:30: in function 'func'
	Module:UnitTests:295: in function 'iterate'
	Module:User:Benwing2/es-verb/testcases:41: in function <Module:User:Benwing2/es-verb/testcases:40>
	(tail call): ?
	[C]: in function 'xpcall'
	Module:UnitTests:369: in function <Module:UnitTests:328>
	(tail call): ?
	mw.lua:527: in function <mw.lua:507>
	[C]: ?
	[C]: in function 'expandTemplate'
	mw.lua:333: in function 'expandTemplate'
	Module:documentation:894: in function 'chunk'
	mw.lua:527: in function <mw.lua:507>
	[C]: ?

local tests = require("Module:UnitTests")
local m_es_verb = require("Module:User:Benwing2/es-verb")
local m_links = require("Module:links")
local lang = require("Module:languages").getByCode("es")

local rsplit = mw.text.split
local rmatch = mw.ustring.match

local function display_raw_code(code)
	local nowiki_code = mw.getCurrentFrame():callParserFunction("#tag:nowiki", code)
	return "<code>" .. nowiki_code .. "</code>"
end

local function link(text)
	return m_links.full_link{ term = text, lang = lang }
end

local reconstruct_verb_spec_examples = {
	{"<ue>", "contar", "contar<ue>"},
	{"", "decir la verdad", "decir<> la verdad"},
	{"((<>,<ue>))", "colar", "((colar<>,colar<ue>))"},
	{"((colar<>,colar<ue>)) el cuello", "colar el cuello", "((colar<>,colar<ue>)) el cuello"},
	{"((colar<>,colar<ue>)) [[el]] [[colo|cuello]]", "colar el cuello", "((colar<>,colar<ue>)) [[el]] [[colo|cuello]]"},
	{"amar", "amar", "amar"},
}

local options = { display = display_raw_code }

function tests:check_reconstruct_verb_spec(orig_spec, lemma, expected_reconstructed_spec)
	local alternant_multiword_spec = m_es_verb.do_generate_forms({[1] = orig_spec, pagename = lemma})
	local actual_reconstructed = m_es_verb.reconstruct_verb_spec(alternant_multiword_spec)
	self:equals(
		display_raw_code(orig_spec) .. "; lemma=" .. link(lemma),
		actual_reconstructed,
		expected_reconstructed_spec,
		options
	)
end

function tests:test()
	self:iterate(reconstruct_verb_spec_examples, "check_reconstruct_verb_spec")
end

return tests