Module:User:Vitalik/inflection-new/testcases

local tests = require('Module:UnitTests') local inflection = require('Module:User:Vitalik/inflection-new') local m_links = require('Module:links')

local data_name = 'ru-noun' local lang = require('Module:languages').getByCode('ru')

local n = 1

function tests:check_inflection(base_stressed, gender_class, stress, expected, comment) local title = base_stressed local link = m_links.full_link({lang = lang, term = title, tr = '-'}, nil, true) local base = mw.ustring.gsub(base_stressed, '́', '') local forms = inflection.main(data_name, base, {base_stressed=base_stressed, gender_class=gender_class, stress=stress}) local forms_keys = {'nom_sg', 'gen_sg', 'dat_sg', 'acc_sg', 'ins_sg', 'prp_sg', 'nom_pl', 'gen_pl', 'dat_pl', 'acc_pl', 'ins_pl', 'prp_pl'} local expected_list = mw.text.split(expected, ' / ') for i, form_key in pairs(forms_keys) do		local zero = i < 10 and '0' or '' local text = n .. '.' .. zero .. i .. ') ' .. link .. ' (' .. gender_class .. ', ' .. stress .. ') ' .. form_key .. ''		text = text .. " stem type is " .. forms['stem_type'] .. " "		if comment then			text = text .. " " .. comment .. " "		end		actual = forms[form_key]		expected = expected_list[i]		self:equals(text, actual, expected)	end	n = n + 1 end

return tests