Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Testcases/Anchor.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-- Unit tests for [[Module:Anchor]]. Click talk page to run tests.

local anchor = require('Module:Anchor') -- the module to be tested
local ScribuntoUnit = require('Module:ScribuntoUnit')
local suite = ScribuntoUnit:new()

function suite:testmain()
self:assertResultEquals('<span class="anchor" id="foo"></span>', '{{#invoke:Anchor|main|foo}}')
self:assertResultEquals('<span class="anchor" id="foo"></span><span class="anchor" id="bar"></span>', '{{#invoke:Anchor|main|foo|bar}}')
self:assertResultEquals('<span class="anchor" id="foo"></span>', '{{#invoke:Anchor|main|3=foo}}')
self:assertResultEquals('<span class="anchor" id="foo"></span>', '{{#invoke:Anchor|main| foo }}')
self:assertResultEquals('<span class="anchor" id="foo"></span>', '{{#invoke:Anchor|main|25=foo}}')
end

function suite:test_main()
self:assertResultEquals('<span class="anchor" id="foo"></span>', anchor._main('foo'))
self:assertResultEquals('<span class="anchor" id="foo"></span><span class="anchor" id="bar"></span>', anchor._main('foo', 'bar'))
end

function suite:testAgainstTemplate()
self:assertSameResult('{{anchor|foo}}', '{{#invoke:Anchor|main|foo}}')
self:assertSameResult('{{anchor|foo|bar}}', '{{#invoke:Anchor|main|foo|bar}}')
self:assertSameResult('{{anchor|3=foo}}', '{{#invoke:Anchor|main|3=foo}}')
end

return suite
76 changes: 76 additions & 0 deletions Testcases/Ancient Greek.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
--[=[
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, Wiktionary, ALA_LC)
tests:equals(
tag(term),
decompose(translit.transliterate(term, "Wiktionary")),
decompose(Wiktionary)
)

tests:equals(
tag(term),
decompose(translit.transliterate(term, "ALA-LC")),
decompose(ALA_LC)
)
end

function tests:test_translit()
local examples = {
{ 'λόγος', 'lógos', 'logos' },
{ 'σφίγξ', 'sphínx', 'sphinx' },
{ 'ϝάναξ', 'wánax', 'wanax' },
{ 'οἷαι', 'hoîai', 'hoiai' },

-- test u/y
{ 'ταῦρος', 'taûros', 'tauros' },
{ 'νηῦς', 'nēûs', 'nēus' },
{ 'σῦς', 'sûs', 'sys' },
{ 'ὗς', 'hûs', 'hys' },
{ 'γυῖον', 'guîon', 'guion' },
{ 'ἀναῡ̈τέω', 'anaṻtéō', 'anayteō' },
{ 'δαΐφρων', 'daḯphrōn', 'daiphrōn' },

-- test length
{ 'τῶν', 'tôn', 'tōn' },
{ 'τοὶ', 'toì', 'toi' },
{ 'τῷ', 'tôi', 'tō' },
{ 'τούτῳ', 'toútōi', 'toutō' },
{ 'σοφίᾳ', 'sophíāi', 'sophia' },
{ 'μᾱ̆νός', 'mānós', 'manos' }, -- should perhaps be mā̆nos

-- test h
{ 'ὁ', 'ho', 'ho' },
{ 'οἱ', 'hoi', 'hoi' },
{ 'εὕρισκε', 'heúriske', 'heuriske' },
{ 'ὑϊκός', 'huïkós', 'hyikos' },
{ 'πυρρός', 'purrhós', 'pyrrhos' },
{ 'ῥέω', 'rhéō', 'rheō' },
{ 'σάἁμον', 'sáhamon', 'sahamon' },

-- test capitals
{ 'Ὀδυσσεύς', 'Odusseús', 'Odysseus' },
{ 'Εἵλως', 'Heílōs', 'Heilōs' },
{ 'ᾍδης', 'Hā́idēs', 'Hadēs' },
{ 'ἡ Ἑλήνη', 'hē Helḗnē', 'hē Helēnē' },

-- punctuation
{ 'ἔχεις μοι εἰπεῖν, ὦ Σώκρατες, ἆρα διδακτὸν ἡ ἀρετή;', 'ékheis moi eipeîn, ô Sṓkrates, âra didaktòn hē aretḗ?', 'echeis moi eipein, ō Sōkrates, ara didakton hē aretē?'},
{ 'τί τηνικάδε ἀφῖξαι, ὦ Κρίτων; ἢ οὐ πρῲ ἔτι ἐστίν;', 'tí tēnikáde aphîxai, ô Krítōn? ḕ ou prṑi éti estín?', 'ti tēnikade aphixai, ō Kritōn? ē ou prō eti estin?' },
-- 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 ō.', 'toutōn phōnēenta men estin hepta; a e ē i o y ō.' },
}

self:iterate(examples, 'check_output')
end

return tests
Loading
Loading