Module:ug-headword/testcases

-- Unit tests for Module:ug-headword. local p = require('Module:UnitTests') local m = require('Module:ug-headword') local test_nouns = require('Module:ug-common/testcases/data')

local function link(word) return "" .. word .. "" end

local function get_Tempalte(vv, change) local par = "" if vv and vv ~= "" then par = par .. "|" .. vv end if change and change ~= "" then par = par .. "|change=" .. change end str = " " return str end

local function get_params(params) local par = {} params = mw.ustring.gsub(params, "|", " ") i=1 for token in mw.ustring.gmatch(params,"[^%s]+") do		t = mw.ustring.gsub(token, "=", " ") j =1 ts={} for tt in mw.ustring.gmatch(t,"[^%s]+") do			ts[j]=tt j=j+1 end

if j ==3 then par[ts[1]] =ts[2] else par[i] = ts[1] i=i+1 end end return par end

function p:check_noun_plurals(singular, expected_plural) if expected_plural.plural then local params = {} if expected_plural.params then params = get_params(expected_plural.params) end local vv = params[1] local change = params["change"] or "yes" local test = m.make_plural_noun(singular, vv, change) local comment = get_Tempalte(vv, change) self:equals(link(singular),			test,			expected_plural.plural,			{comment = get_Tempalte(params[1], params["change"])}) end end

function p:test_checkPlurals p:iterate(test_nouns, "check_noun_plurals") end

return p