Module:yue-pron/testcases

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

2 of 2 tests failed. (refresh)

TextExpectedActual
test_IPA_conv:
Failedjau3 zi6 jyun4-2 (幼稚園)jɐu̯˧ t͡siː˨ jyːn˨˩꜔꜒jɐu̯³³ t͡siː²² jyːn²¹⁻³⁵
Failedzung1 waa4 (中華)t͡sʊŋ˥ wɑː˨˩t͡sʊŋ⁵ waː²¹

local tests = require("Module:UnitTests")

local m_pron = require("Module:yue-pron")

local function code(text)
	return '<code>' .. text .. '</code>'
end

local function link(text)
	return '<span class="Hani" lang="zh">[[' .. text .. '#Chinese|' .. text .. ']]</span>'
end

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

local function show(yue, zh)
	return code(yue) .. " (" .. link(zh) .. ")"
end

local function remove_html(text)
	text = text:gsub("<[^>]+>", "")
	return text
end

local options = { display = tag_IPA, show_difference = true }
function tests:check(funcName)
	local func = m_pron[funcName] or error('No function called "' .. funcName .. '" in Module:wuu-pron.')
	return function (self, example, entry, actual)
		self:equals(show(example, entry), remove_html(func(example)), actual, options)
	end
end

function tests:test_IPA_conv()
	local examples = {
		{ "jau3 zi6 jyun4-2", "幼稚園", "jɐu̯˧ t͡siː˨ jyːn˨˩꜔꜒" },
		{ "zung1 waa4", "中華", "t͡sʊŋ˥ wɑː˨˩" },
	}
	self:iterate(examples, self:check("jyutping_to_ipa"))
end

return tests