Jump to content

Module:got-adjective/testcases

From Wiktionary, the free dictionary


local gotadj = require("Module:got-adjective")
local translit = require("Module:Goth-translit")
local ScribuntoUnit = require("Module:ScribuntoUnit")
local suite = ScribuntoUnit:new()

local function mkframe(args)
	local parent = {}
	local child = {}
	parent.getParent = function (self) return nil end
	child.getParent = function (self) return parent end
	parent.args = args
	child.args = args
	
    return child
end

local function tblhdr(stem) return [[
{| class="wikitable inflection-table vsSwitcher" style="border-style: double; border-width: 3px;" cellspacing="1"
|-
! class="vsToggleElement" style="background: #CCC; min-width: 44em; text-align: left;" colspan="4" | ]] .. stem end

local function inflhdr(inflection) return [[
|- class="vsHide"
! style="background: #DDD;" colspan="4" | ]] .. inflection end

local function numberhdr(number) return [[
|- class="vsHide"
! style="min-width: 8em;" | ]] .. number .. '\n' .. [[
! style="min-width: 12em;" | Masculine 
! style="min-width: 12em;" | Feminine 
! style="min-width: 12em;" | Neuter 
]] end

local function casehdr(case) return [[
|- class="vsHide"
! ]] .. case end

local function entry(Latn)
	local nomacron = {
		['ā'] = 'a',
		['ē'] = 'e',
		['ī'] = 'i',
		['ō'] = 'o',
		['ū'] = 'u'
	}
	local Goth = {}
	for i, t in ipairs(Latn) do
		Goth[i] = translit.tr_reverse(Latn[i])
	end
	local result = { '| ' }
	for i, t in ipairs(Goth) do
		if i > 1 then table.insert(result, ', ') end
		table.insert(result, '<span class="Goth" lang="got">[[')
		table.insert(result, t)
		table.insert(result, '#Gothic|')
		table.insert(result, t)
		table.insert(result, ']]</span>')
	end
	table.insert(result, '<br/>')
	for i, t in ipairs(Latn) do
		local n = mw.ustring.gsub(t, "[āēīōū]", nomacron)
		if i > 1 then table.insert(result, ', ') end
		table.insert(result, '<span class="None" lang="got">[[')
		table.insert(result, n)
		table.insert(result, '#Gothic|')
		table.insert(result, t)
		table.insert(result, ']]</span>')
	end
	return table.concat(result)
end

function suite:test_a_adjective()
	self:assertEquals(table.concat({
		tblhdr('A-stem '),
		inflhdr('Strong (indefinite) inflection '),
		numberhdr('Singular '),
		casehdr('Nominative '), entry{'agls'}   , entry{'agla'}    , entry{'agl', 'aglata'},
		casehdr('Accusative '), entry{'aglana'} , entry{'agla'}    , entry{'agl', 'aglata'},
		casehdr('Genitive ')  , entry{'aglis'}  , entry{'aglaizōs'}, entry{'aglis'}        ,
		casehdr('Dative ')    , entry{'aglamma'}, entry{'aglai'}   , entry{'aglamma'}      ,
		numberhdr('Plural '),
		casehdr('Nominative '), entry{'aglai'}  , entry{'aglōs'}   , entry{'agla'}         ,
		casehdr('Accusative '), entry{'aglans'} , entry{'aglōs'}   , entry{'agla'}         ,
		casehdr('Genitive '), entry{'aglaizē'}  , entry{'aglaizō'} , entry{'aglaizē'}      ,
		casehdr('Dative '), entry{'aglaim'}     , entry{'aglaim'}  , entry{'aglaim'}       ,
		inflhdr('Weak (definite) inflection '),
		numberhdr('Singular '),
		casehdr('Nominative '), entry{'agla'}   , entry{'aglō'}    , entry{'aglō'}         ,
		casehdr('Accusative '), entry{'aglan'}  , entry{'aglōn'}   , entry{'aglō'}         ,
		casehdr('Genitive ')  , entry{'aglins'} , entry{'aglōns'}  , entry{'aglins'}       ,
		casehdr('Dative ')    , entry{'aglin'}  , entry{'aglōn'}   , entry{'aglin'}        ,
		numberhdr('Plural '),
		casehdr('Nominative '), entry{'aglans'} , entry{'aglōns'}  , entry{'aglōna'}       ,
		casehdr('Accusative '), entry{'aglans'} , entry{'aglōns'}  , entry{'aglōna'}       ,
		casehdr('Genitive ')  , entry{'aglanē'} , entry{'aglōnō'}  , entry{'aglanē'}       ,
		casehdr('Dative ')    , entry{'aglam'}  , entry{'aglōm'}   , entry{'aglam'}        ,
		'|}'
	}, '\n'), gotadj.a(mkframe{"agl"}))
end

return suite