Module:sandbox/ms-pron/testcases


Module error: No such module "ms-pron/sandbox/testcases".


local tests = require("Module:UnitTests")
local m_ms_pron = require("Module:ms-pron/sandbox")
local m_links = require('Module:links')
local ms = require('Module:languages').getByCode('ms')

local function link(text)
	return m_links.full_link{ term = text, lang = ms }
end

local options = { display = tag_IPA }

local function check_ipa(self, word, phonetic, expected_Joh, expected_Baku, respelling, comment)
	local Johor = m_ms_pron.IPA(word, "piawai", phonetic).text
	local Baku = m_ms_pron.IPA(word, "baku", phonetic).text
	local show_all = Baku ~= Northern ~= Johor
	
	options.comment = show_all and 'Johor' .. (comment or '') or comment
	self:equals(
		link(word),
		Johor,
		expected_Joh,
		options
	)
	if show_all then
		options.comment = show_both and 'Baku' .. (comment or '') or comment
		self:equals(
			link(word),
			Baku,
			expected_Baku,
			options
		)
	end
end

function tests:check_phonetic_ipa(word, expected_Joh, expected_Baku, comment)
	check_ipa(self, word, true, expected_Joh, expected_Baku, comment)
end

function tests:check_phonemic_ipa(word, expected_Joh, expected_Baku, comment)
	check_ipa(self, word, false, expected_Joh, expected_Baku, comment)
end

function tests:test_phonetic_pron()
	local examples = {
        { "air", "ˈa.ɛr", "ˈa.ir" },
        { "anjing", "ˈan.d͡ʒɛŋ", "ˈan.d͡ʒiŋ" },
        { "baik", "ˈba.ɛʔ", "ˈba.ɛʔ", "baiq" },
        { "buka", "ˈbu.kə", "ˈbu.ka" },
        { "cuci","ˈt͡ʃu.t͡ʃi"},
		{ "datang", "ˈda.t̪aŋ" },
        { "Februari","feˈbrwa.ri", "fe.bruˈa.ri", "Fe.bruari" },
        { "gajah", "ˈɡa.d͡ʒah" },
		{ "gereja", "ɡəˈre.d͡ʒə",  "ɡəˈre.d͡ʒə", "geréja" },
		{ "gunung","ˈɡu.noŋ", "ˈɡu.nuŋ"},
        { "hijau","ˈhi.d͡ʒau̯"},
		{ "khidmat", "ˈxit̪.mat̪"},
        { "laut", "ˈla.ot̪", "ˈla.ut̪" },
        { "nasionalisme", "na.sjo.naˈlis.mə", "na.si.o.naˈlis.mə" },
        { "nikmat", "ˈniʔ.mat̪", "niqmat" },
        { "nya", "ɲə", "ɲa"},
        { "pakaian","paˈka.jan"},
        { "pantai", "ˈpan.t̪ai̯"},
        { "pulau", "ˈpu.lau̯", "pulau" },
		{ "Qur'an", "kuˈran", "Kurān"},
        { "rakyat", "ˈraʔ.jat̪", "raqyat" },
		{ "selamat", "səˈla.mat̪"},
		{ "syarat", "ˈʃa.rat̪"},
		{ "tidak", "ˈt̪i.daʔ"},
	}
	self:iterate(examples, "check_phonetic_ipa")
end

return tests