Module:haw-IPA/testcases

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 ' [' .. IPA .. '] ' or ' /' .. IPA .. '/ ' 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" }, { "iā", false, "iˈaː", "syllable-final stress" }, { "ʻ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" }, { "kea", true, "ˈkɛ.jə", "glide insertion"}, { "kau", true, "ˈkɐw, ˈkɔw", "rapid pronunciation" }, }

self:iterate(examples, "check_output") end

return tests