Module:grc-utilities/sandbox/testcases

Wiktionary වෙතින්

All tests passed. (refresh)

TextExpectedActual
testMakeEntryName:
Passedἐᾱ́νἐάνἐάν
Passedᾰ̓́νερἄνερἄνερ
PassedΠηληῐ̈ᾰ́δηςΠηληϊάδηςΠηληϊάδης
PassedᾹ̔́ͅδηςᾍδηςᾍδης
TextExpectedActual
testMakeSortKey:
Passedἐᾱ́νΕΑΝΕΑΝ
Passedᾰ̓́νερΑΝΕΡΑΝΕΡ
PassedΠηληῐ̈ᾰ́δηςΠΗΛΗΙΑΔΗΣΠΗΛΗΙΑΔΗΣ
PassedᾹ̔́ͅδηςΑΔΗΣΑΔΗΣ

local tests = require("Module:UnitTests")

local m_utilities_sandbox = require("Module:grc-utilities/sandbox")
local makeSortKey = m_utilities_sandbox.makeSortKey
local makeEntryName = m_utilities_sandbox.makeEntryName
local normalize = mw.ustring.toNFD

--[=[
-- Compare functions in [[Module:languages]].
local grc = require("Module:languages").getByCode("grc")
local function makeSortKey(text)
	return grc:makeSortKey(text)
end
local function makeEntryName(text)
	return grc:makeEntryName(text)
end
--]=]

local function tag(text)
	return '<span class="polytonic" lang="grc">' .. text .. '</span>'
end

local options = { display = tag }
function tests:check(func)
	return function (self, example, expected)
		self:equals(tag(example), normalize(func(example)), normalize(expected), options)
	end
end

function tests:testMakeEntryName()
	local examples = {
		{ "ἐᾱ́ν", "ἐάν" },
		{ "ᾰ̓́νερ", "ἄνερ" },
		{ "Πηληῐ̈ᾰ́δης", "Πηληϊάδης" },
		{ "Ᾱ̔́ͅδης", "ᾍδης" },
		--[[
		{ "", "" },
		{ "", "" },
		--]]
	}
	self:iterate(examples, self:check(makeEntryName))
end

function tests:testMakeSortKey()
	local examples = {
		{ "ἐᾱ́ν", "ΕΑΝ" },
		{ "ᾰ̓́νερ", "ΑΝΕΡ" },
		{ "Πηληῐ̈ᾰ́δης", "ΠΗΛΗΙΑΔΗΣ" },
		{ "Ᾱ̔́ͅδης", "ΑΔΗΣ" },
		--[[
		{ "", "" },
		{ "", "" },
		--]]
	}
	self:iterate(examples, self:check(makeSortKey))
end
	

return tests
"https://si.wiktionary.org/w/index.php?title=Module:grc-utilities/sandbox/testcases&oldid=26182" වෙතින් සම්ප්‍රවේශනය කෙරිණි