Misplaced Pages

Module:Wikt-lang/testcases: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
< Module:Wikt-lang Browse history interactivelyNext edit →Content deleted Content added
Revision as of 18:39, 23 June 2018 editErutuon (talk | contribs)Autopatrolled, Extended confirmed users32,173 edits start testcases  Revision as of 18:41, 23 June 2018 edit undoErutuon (talk | contribs)Autopatrolled, Extended confirmed users32,173 edits fix normalization issueNext edit →
Line 21: Line 21:
end end


local decompose = mw.ustring.toNFD
function p:check_makeEntryName(languageCode, word, expected) function p:check_makeEntryName(languageCode, word, expected)
self:equals(word, m_Language.makeEntryName(word, languageCode), expected) self:equals(
word,
decompose(m_Language.makeEntryName(word, languageCode)),
decompose(expected))
end end



Revision as of 18:41, 23 June 2018

This is the test cases page for the module Module:Wikt-lang. Results of the test cases.
-- Example Unit tests for ]. Click talk page to run tests.
local p = require 'Module:UnitTests'
local m_Language = require 'Module:Language'

function p:iterate(examples, func)
	if type(examples) ~= 'table' then
		error('First argument of iterate should be a table, not ' .. type(examples) .. '.')
	end
	if type(func) == 'string' then
		func = self
		for i, example in ipairs(examples) do
			if type(example) == 'table' then
				func(self, unpack(example))
			else
				error('iterate does not know what to do with example number ' .. i .. ', whose type is ' .. type(example) .. '.')
			end
		end
	else
		error('Second argument of iterate should be a string, not ' .. type(func) .. '.')
	end
end

local decompose = mw.ustring.toNFD
function p:check_makeEntryName(languageCode, word, expected)
	self:equals(
		word,
		decompose(m_Language.makeEntryName(word, languageCode)),
		decompose(expected))
end

p = function (self)
	local examples = {
		{ "la", "homō", "homo" },
		{ "grc", "δημοκρᾰτῐ́ᾱ", "δημοκρατία" },
	}
	
	self:iterate(examples, "check_makeEntryName")
end

return p
Category: