Module:User:AmazingJus/sce/testcases

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

2 of 9 tests failed. (refresh)

TextExpectedActual
test_phonemic_IPA:
Passedbaer/pɑˈɚ//pɑˈɚ/
Passedtiigha/tʰɯˈqɑ//tʰɯˈqɑ/
Passedniere/njəˈrə//njəˈrə/
Passedenzhegve/ənt͡ʂəˈʁə//ənt͡ʂəˈʁə/
Passedxiaojierun (xiaojieruŋ)/ɕjɑwt͡ɕjəˈruŋ//ɕjɑwt͡ɕjəˈruŋ/
Passedershi ('ershi)/ˈɚʂi//ˈɚʂi/
Passedruhher ('ruhher)/ˈʐuhɚ//ˈʐuhɚ/
TextExpectedActual
test_phonetic_IPA:
Failedkorolon[kʰoroˈlõŋ][k⁽ʷ⁾or⁽ʷ⁾ol⁽ʷ⁾õn]
Failedhotou[xʷoˈtəu̯~xʷoˈtɤu̯][h⁽ʷ⁾otəu̯ ~ h⁽ʷ⁾otɤu̯]

local tests = require("Module:UnitTests")
local m_IPA = require("Module:User:AmazingJus/sce")
local gsub = mw.ustring.gsub

local sce = require("Module:languages").getByCode("sce")
local function link(text)
	return require("Module:links").full_link { term = text, lang = sce }
end

local function respell(term)
    local original_term = term
    term = gsub(term, "'", ""):gsub("ŋ", "n")
    return term, original_term ~= term and term or nil
end

function tests:test_phonemic_IPA()
	local testcases = {
		{ "baer", "pɑˈɚ" },
		{ "tiigha", "tʰɯˈqɑ" },
		{ "niere", "njəˈrə" },
		{ "enzhegve", "ənt͡ʂəˈʁə" },
		{ "xiaojieruŋ", "ɕjɑwt͡ɕjəˈruŋ" },
		{ "'ershi", "ˈɚʂi", "zh" },
		{ "'ruhher", "ˈʐuhɚ", "zh" }
	}

	local options = {
		display = function(IPA)
			return '<span class="IPA">/' .. IPA .. '/</span>'
		end
	}

	self:iterate(testcases, function(self, term, IPA, etyl)
		local respelt, is_respelt = respell(term)

		if is_respelt then
			self:equals(link(respelt) .. " (<code>" .. term .. "</code>)", m_IPA.IPA_m(term, etyl), IPA, options)
		else
			self:equals(link(term), m_IPA.IPA_m(term, etyl), IPA, options)
		end
	end)
end

function tests:test_phonetic_IPA()
	local testcases = {
		{ "korolon", "kʰoroˈlõŋ" },
		{ "hotou", "xʷoˈtəu̯~xʷoˈtɤu̯" }
	}

	local options = {
		display = function(IPA)
			return '<span class="IPA">[' .. IPA .. ']</span>'
		end
	}

	self:iterate(testcases, function(self, term, IPA, etyl)
		local respelt, is_respelt = respell(term)

		if is_respelt then
			self:equals(link(respelt) .. " (<code>" .. term .. "</code>)", m_IPA.IPA_t(term, etyl), IPA, options)
		else
			self:equals(link(term), m_IPA.IPA_t(term, etyl), IPA, options)
		end
	end)
end

return tests