Module:haw-IPA/testcases

All tests passed. (refresh)

TextExpectedActualComments
test_all:
Passedhumuhumunukunukuāpuaʻa/ˌhu.muˌhu.muˌnu.kuˌnu.kuˌaː.puˈa.ʔa//ˌhu.muˌhu.muˌnu.kuˌnu.kuˌaː.puˈa.ʔa/compound word
Passedʻōmaʻimaʻi au/ˌʔoː.ma.ʔiˈma.ʔi ˈau̯//ˌʔoː.ma.ʔiˈma.ʔi ˈau̯/compound word, multiword
Passedʻeleʻele[ˌʔɛ.lɛˈʔɛ.lɛ][ˌʔɛ.lɛˈʔɛ.lɛ]compound word, allophony
Passedʻaleʻale[ˌʔɐ.leˈʔɐ.le][ˌʔɐ.leˈʔɐ.le]compound word, allophony
Passedpepeiao[pe.pejˈjɐo̯][pe.pejˈjɐo̯]glide insertion
Passedpuana[puˈwɐ.nə][puˈwɐ.nə]glide insertion
Passedmoana[moˈwɐ.nə][moˈwɐ.nə]glide insertion
Passedkau[ˈkɐw, ˈkɔw][ˈkɐw, ˈkɔw]rapid pronunciation

local tests = require("Module:UnitTests")
local ipa = require("Module:haw-IPA")
local link = require("Module:links")

local lang = require("Module:languages").getByCode("haw")
local sc = require("Module:scripts").getByCode("Latn")

local function tag_IPA(IPA, is_phonetic)
	return is_phonetic and '<span class="IPA">[' .. IPA .. ']</span>' or '<span class="IPA">/' .. IPA .. '/</span>'
end

function tests:check_output(term, is_phonetic, expected, comment)
	local actual = ipa.toIPA(term, is_phonetic)
	if ipa.rapid(ipa.toIPA(term, is_phonetic)) ~= actual then
		actual = actual .. ", " .. ipa.rapid(ipa.toIPA(term, is_phonetic))
	end

	self:equals(
		link.full_link({ term = mw.ustring.gsub(term, "[%+]", ""), lang = lang, sc = sc } ),
		tag_IPA(actual, is_phonetic),
		tag_IPA(expected, is_phonetic),
		{ comment = comment }
	)
end

function tests:test_all()
	examples = {
		{ "humu+humu+nuku+nuku+āpu+aʻa", false, "ˌhu.muˌhu.muˌnu.kuˌnu.kuˌaː.puˈa.ʔa", "compound word" },
		{ "ʻōma+ʻimaʻi au", false , "ˌʔoː.ma.ʔiˈma.ʔi ˈau̯", "compound word, multiword" },
		{ "ʻele+ʻele", true, "ˌʔɛ.lɛˈʔɛ.lɛ", "compound word, allophony" },
		{ "ʻale+ʻale", true, "ˌʔɐ.leˈʔɐ.le", "compound word, allophony" },
		{ "pepeiao", true, "pe.pejˈjɐo̯", "glide insertion" },
		{ "puana", true, "puˈwɐ.nə", "glide insertion" },
		{ "moana", true, "moˈwɐ.nə", "glide insertion" },
		{ "kau", true, "ˈkɐw, ˈkɔw", "rapid pronunciation" },
	}

	self:iterate(examples, "check_output")
end

return tests