Module:gu-IPA/sandbox/testcases

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

local tests = require("Module:UnitTests")
local m_IPA = require("Module:gu-IPA/sandbox")

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

function tests:check_output(term, expected, comment)
	self:equals(
		m_IPA.link(term),
		tag_IPA(m_IPA.toIPA(term)),
		tag_IPA(expected),
		{ comment = comment }
	)
end

function tests:test_all()
	examples = {
		{ "વખત", "ˈʋə.kʰət̪" },
		{ "દિવસ", "ˈd̪ɪ.ʋəs" },
		{ "હદ", "ˈɦəd̪" },
		{ "રહેવું", "ˈre̤.ʋũ" }, -- final syllables use their 'long vowel' counterpart
		{ "તડકો", "ˈt̪əɖ.ko" },
		{ "ભાષા", "ˈbʱɑ.ʃɑ" },
		{ "છોકરું", "ˈt͡ʃʰok.rũ" },
		{ "ઘોડું", "ˈɡʱo.ɖũ" },
		{ "દૃષ્ટિ", "ˈd̪rəʂʈi" },
		{ "દૃષ્ટિ", "ˈd̪rʊʂʈi" },
		{ "ગુજરાતી", "ˈgʊ.d͡ʒ(ə).ˌɾɑ.t̪i" },
		{ "પ્રાણી", "ˈpɾɑ.ɳi" },
		{ "સાક્ષાત", "ˈsɑ.kʃɑt̪" },
		{ "જમવાનું", "ˈd͡ʒəm.ˌʋɑ.nũ" },
		{ "વિધર્મ", "ʋɪ.d̪ʱəɾ.mə" },
		{ "અંગરખો", "ˈəŋ.gəɾ.kʱo" },
		{ "આંતરરાષ્ટ્રીય", "ˈɑn̪.t̪əɾ.ɾɑʂ.ʈɾi.jə" },
		{ "આંકડાશાસ્ત્ર", "ˈɑ̃.k(ə).ɖɑ.ʃɑs.t̪ɾə" },
		{ "અહીંતહીં", "ˈə̤ĩ.ˌt̪ə̤ĩ" },
		{ "ઐતિહાસિક", "əɪ̭.t̪ɪ.ɦɑ.sɪk" },
		{ "ઇસ્પિતાલ", "ˈɪs.pɪ.ˌt̪ɑl" },
		{ "ઉષ્ણાગ્ર", "ˈʊʃ.ɳɑ.gɾə" },
		{ "ઓળખકર્તા", "ˈo.ɭəkʱ.ˌkəɾ.t̪ɑ" },
	}
--[[	Copy the following to add more examples:
		{ "", "" },
]]
	
	tests:iterate(examples, "check_output")
end

return tests