Jump to content

Module:Ancient Greek/testcases

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Erutuon (talk | contribs) at 23:53, 21 October 2017 (Cypriot not supported). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
--[=[
	Modified from [[wikt:Module:grc-translit/testcases]].
]=]

local tests = require('Module:UnitTests')
local translit = require('Module:Ancient Greek')
local decompose = mw.ustring.toNFC

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

function tests:check_output(term, expected, sc)
	tests:equals(
		tag(term),
		decompose(translit.transliterate(term)),
		decompose(expected)
	)
end

function tests:iterate(examples, func)
	for i, example in ipairs(examples) do
		self[func](self, unpack(example))
	end
end

function tests:test_translit()
	local examples = {
		{ 'λόγος', 'lógos' },
		{ 'σφίγξ', 'sphínx' },
		{ 'ϝάναξ', 'wánax' },
		{ 'οἷαι', 'hoîai' },
		
		-- test u/y
		{ 'ταῦρος', 'taûros' },
		{ 'νηῦς', 'nēûs' },
		{ 'σῦς', 'sûs' },
		{ 'ὗς', 'hûs' },
		{ 'γυῖον', 'guîon' },
		{ 'ἀναῡ̈τέω', 'anaṻtéō' },
		{ 'δαΐφρων', 'daḯphrōn' },
		
		-- test length
		{ 'τῶν', 'tôn' },
		{ 'τοὶ', 'toì' },
		{ 'τῷ', 'tôi' },
		{ 'τούτῳ', 'toútōi' },
		{ 'σοφίᾳ', 'sophíāi' },
		{ 'μᾱ̆νός', 'mānós' }, -- should perhaps be mā̆nos
		
		-- test h
		{ 'ὁ', 'ho' },
		{ 'οἱ', 'hoi' },
		{ 'εὕρισκε', 'heúriske' },
		{ 'ὑϊκός', 'huïkós' },
		{ 'πυρρός', 'purrhós' },
		{ 'ῥέω', 'rhéō' },
		{ 'σάἁμον', 'sáhamon' },
	
		-- test capitals
		{ 'Ὀδυσσεύς', 'Odusseús' },
		{ 'Εἵλως', 'Heílōs' },
		{ 'ᾍδης', 'Hā́idēs' },
		{ 'ἡ Ἑλήνη', 'hē Helḗnē' },
		
		-- punctuation
		{ 'ἔχεις μοι εἰπεῖν, ὦ Σώκρατες, ἆρα διδακτὸν ἡ ἀρετή;', 'ékheis moi eipeîn, ô Sṓkrates, âra didaktòn hē aretḗ?'},
		{ 'τί τηνικάδε ἀφῖξαι, ὦ Κρίτων; ἢ οὐ πρῲ ἔτι ἐστίν;', 'tí tēnikáde aphîxai, ô Krítōn? ḕ ou prṑi éti estín?' },
		-- This ought to be colon, but sadly that cannot be.
		{ 'τούτων φωνήεντα μέν ἐστιν ἑπτά· α ε η ι ο υ ω.', 'toútōn phōnḗenta mén estin heptá; a e ē i o u ō.' },
	}
	
	self:iterate(examples, 'check_output')
end

return tests