Module:is-pronunciation/testcases

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

All tests passed. (refresh)

TextExpectedActual
test_pron:
Passedþornˈθɔrtn̥ˈθɔrtn̥
Passedhiminnˈhɪːmɪnːˈhɪːmɪnː
Passedbrúnnˈprutn̥ˈprutn̥
Passedsteinnˈstɛi̯tn̥ˈstɛi̯tn̥
Passedgeimsteinn (respelled geim-steinn)ˈcɛi̯mstɛi̯tn̥ˈcɛi̯mstɛi̯tn̥
Passedkarlˈkʰartl̥ˈkʰartl̥
Passedruslˈrʏstl̥ˈrʏstl̥
Passedbysnaˈpɪstn̥aˈpɪstn̥a
Passedráps (respelled ráp.s)ˈrau̯ːpsˈrau̯ːps
Passedtakaˈtʰaːkaˈtʰaːka
Passedþökkˈθœhkˈθœhk
Passedvopnˈvɔhpn̥ˈvɔhpn̥
Passedbrotnaˈprɔhtn̥aˈprɔhtn̥a
Passedsaknaˈsahkn̥aˈsahkn̥a
Passedkembtˈcʰɛm̥tˈcʰɛm̥t
Passedþiðˈθɪːðˈθɪːð
Passedguðˈkvʏːðˈkvʏːð
Passedbyggjaˈpɪcːaˈpɪcːa
Passedsyngjaˈsincaˈsinca
Passedmunkurˈmuŋkʏrˈmuŋkʏr
Passedöngullˈœy̯ŋkʏtl̥ˈœy̯ŋkʏtl̥
Passeddrengurˈtrɛi̯ŋkʏrˈtrɛi̯ŋkʏr
Passedsvangurˈsvau̯ŋkʏrˈsvau̯ŋkʏr
PassedEnglandˈɛi̯ŋlantˈɛi̯ŋlant
Passedsegjaˈsɛi̯ːjaˈsɛi̯ːja
Passedflugaˈflʏːɣaˈflʏːɣa
Passedfljúgaˈfljuːaˈfljuːa
Passedbógurˈpou̯ːʏrˈpou̯ːʏr
Passedlágurˈlau̯ːʏrˈlau̯ːʏr
Passedprófaˈpʰrou̯ːaˈpʰrou̯ːa
Passeddagsˈtaxsˈtaxs
Passeddragtˈtraxtˈtraxt
Passedguðspjall (respelled guð-spjall)ˈkvʏðspjatl̥ˈkvʏðspjatl̥
Passedseptemberˈsɛftɛmpɛrˈsɛftɛmpɛr
Passedoktóberˈɔxtou̯pɛrˈɔxtou̯pɛr
Passedgjaldaˈcaltaˈcalta
Passedgetaˈcɛːtaˈcɛːta
Passedkjósaˈcʰou̯ːsaˈcʰou̯ːsa
Passedkeyraˈcʰɛi̯ːraˈcʰɛi̯ːra
Passedkirkjaˈcʰɪrcaˈcʰɪrca
Passedhlýrˈl̥iːrˈl̥iːr
Passedhrattˈr̥ahtˈr̥aht
Passedsparaˈspaːraˈspaːra
Passedþykjaˈθɪːcaˈθɪːca
Passedlofaˈlɔːvaˈlɔːva
Passedrósˈrou̯ːsˈrou̯ːs
Passedvaxaˈvaxsaˈvaxsa
Passedmylla, special=trueˈmɪlːaˈmɪlːa
Passednuddaˈnʏtːaˈnʏtːa
Passedkaþólikkiˈkʰaːθou̯lɪhcɪˈkʰaːθou̯lɪhcɪ

local tests = require("Module:UnitTests")
local m_IPA = require("Module:is-pronunciation")

local gsub = mw.ustring.gsub
local format = mw.ustring.format

local function tag_IPA(IPA)
	return '<span class="IPA">' .. IPA .. '</span>'
end

local function generate_link(term)
	return gsub(term, "[%-%.]", "")
end

function tests:check_output(term, expected, respell, accent, special)
	local generated_link = generate_link(term)
	local respelled_term = respell or term

	return tests:equals(
		m_IPA.tag_text(m_IPA.link(generated_link)) ..
			(respelled_term ~= generated_link and format(" (respelled %s)", m_IPA.tag_text(respelled_term)) or "") ..
			(special and ", special=true" or ""), 
		m_IPA.toIPA(term, accent, special), 
		expected, 
		{ display = tag_IPA } 
	)
end

function tests:test_pron()
	local list = {
		{"þorn", "ˈθɔrtn̥" },
		{"himinn", "ˈhɪːmɪnː" },
		{"brúnn", "ˈprutn̥" },
		{"steinn", "ˈstɛi̯tn̥" },
		{"geim-steinn", "ˈcɛi̯mstɛi̯tn̥" },
		{"karl", "ˈkʰartl̥" },
		{"rusl", "ˈrʏstl̥" },
		{"bysna", "ˈpɪstn̥a" },
		{"ráp.s", "ˈrau̯ːps" },
		{"taka", "ˈtʰaːka" },
		{"þökk", "ˈθœhk" },
		{"vopn", "ˈvɔhpn̥" },
		{"brotna", "ˈprɔhtn̥a" },
		{"sakna", "ˈsahkn̥a" },
		{"kembt", "ˈcʰɛm̥t" },
		{"þið", "ˈθɪːð" },
		{"guð", "ˈkvʏːð" },
		{"byggja", "ˈpɪcːa" },
		{"syngja", "ˈsinca" },
		{"munkur", "ˈmuŋkʏr" },
		{"öngull", "ˈœy̯ŋkʏtl̥"},
		{"drengur", "ˈtrɛi̯ŋkʏr" },
		{"svangur", "ˈsvau̯ŋkʏr" },
		{"England", "ˈɛi̯ŋlant" },
		{"segja", "ˈsɛi̯ːja" },
		{"fluga", "ˈflʏːɣa" },
		{"fljúga", "ˈfljuːa" },
		{"bógur", "ˈpou̯ːʏr" },
		{"lágur", "ˈlau̯ːʏr" },
		{"prófa", "ˈpʰrou̯ːa" },
		{"dags", "ˈtaxs" },
		{"dragt", "ˈtraxt" },
		{"guð-spjall", "ˈkvʏðspjatl̥" },
		{"september", "ˈsɛftɛmpɛr" },
		{"október", "ˈɔxtou̯pɛr" },
		{"gjalda", "ˈcalta" },
		{"geta", "ˈcɛːta" },
		{"kjósa", "ˈcʰou̯ːsa" },
		{"keyra", "ˈcʰɛi̯ːra" },
		{"kirkja", "ˈcʰɪrca" },
		{"hlýr", "ˈl̥iːr" },
		{"hratt", "ˈr̥aht" },
		{"spara", "ˈspaːra" },
		{"þykja", "ˈθɪːca" },
		{"lofa", "ˈlɔːva" },
		{"rós", "ˈrou̯ːs" },
		{"vaxa", "ˈvaxsa" },
		{"mylla", "ˈmɪlːa", nil, nil, true },
		{"nudda", "ˈnʏtːa" },
		{"kaþólikki", "ˈkʰaːθou̯lɪhcɪ" }
	}
	self:iterate(list, "check_output")
end

--[[
			Additions take this form –
		{ "entry name", "IPA" },
		{ "", "" },
			or, if you are generating IPA from a respelling of the term –
		{ "respelling", "IPA", "entry name" }
		{ "", "", "" },
			Make sure to include the comma, or the module will return an error.
]]--

return tests