Module:mn-IPA/testcases: difference between revisions

From Wiktionary, the free dictionary
Jump to navigation Jump to search
Content deleted Content added
crappy examples to test pre-punctuation and string-end environments
respelling of монгол хэл
Line 16: Line 16:
function tests:test_phonemic_IPA()
function tests:test_phonemic_IPA()
local examples = {
local examples = {
{ 'монгол хэл', 'mɔŋɡɔɮ xeɮ' },
{ 'монгол хэл', 'mɔŋɡəɮ xeɮ', 'монгәл хэл' },
{ 'сайн байна уу', 'saiŋ pain ʊː' },
{ 'сайн байна уу', 'saiŋ pain ʊː' },
{ 'сайн!', 'saiŋ!' },
{ 'сайн!', 'saiŋ!' },

Revision as of 05:50, 30 April 2019

4 of 4 tests failed. (refresh)

TextExpectedActual
test_phonemic_IPA:
Failedмонгәл хэлмонгол хэл (mongol xel)/mɔŋɡəɮ xeɮ//ˈmɔŋkəɮ xeɮ/
Failedсайн байна уу (sajn bajna uu)/saiŋ pain ʊː//ˈsɛːm pɛːn ʊː/
Failedсайн! (sajn!)/saiŋ!//ˈsɛːŋ!/
Failedсайн (sajn)/saiŋ//ˈsɛːŋ/

local tests = require 'Module:UnitTests'

local to_IPA = require 'Module:mn-IPA'.to_IPA

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

local tag_text = require 'Module:script utilities'.tag_text
local function tag(text)
	return tag_text(text, mn)
end

function tests:test_phonemic_IPA()
	local examples = {
		{ 'монгол хэл', 'mɔŋɡəɮ xeɮ', 'монгәл хэл' },
		{ 'сайн байна уу', 'saiŋ pain ʊː' },
		{ 'сайн!', 'saiŋ!' },
		{ 'сайн', 'saiŋ' },
	}
	
	local options = {
		display = function (IPA)
			return '<span class="IPA">/' .. IPA .. '/</span>'
		end
	}
	self:iterate(examples, function (self, term, IPA, respelling)
		local term_display = link(term)
		
		if respelling then
			term_display = tag(respelling) .. ' – ' .. term_display
		end
		
		self:equals(term_display, to_IPA(respelling or term), IPA, options)
	end)
end

return tests