Module:User:AmazingJus/sco/testcases

This is a private module sandbox of AmazingJus, for his own experimentation. Items in this module may be added and removed at AmazingJus's discretion; do not rely on this module's stability.


local tests = require("Module:UnitTests")
local ipa = require("Module:User:AmazingJus/sco")

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

function tests:check_IPA(term, func, expected, comment)
	self:equals(
		ipa.link(term),
		tag_IPA(mw.ustring.toNFC(func(term))),
		tag_IPA(expected),
		{ comment = comment, show_difference = true }
	)
end

function tests:test_pron()
	local examples = {
		{ "stane", "ˈsten", "" },
		{ "yowe", "ˈsten", "ˈjʌʉː" },
		{ "thousand", "ˈsten", "ˈhʉːzən" },
		{ "traivel", "ˈsten", "ˈtreːvəl" },
		{ "efternuin", "ˈsten", "ˌɛftərˈnøn" }
	}
	--[[	Copy the following to add more examples:
		{ "", "", "" },
	]]

	for _, example in ipairs(examples) do
		local term, expected, comment = unpack(example)
		self:check_IPA(term, ipa.toIPA, expected, comment)
	end
end

return tests