Module:accel/grc/testcases
Appearance
< Module:accel | grc
- පහත දැක්වෙන උපදෙස්, Module:accel/grc/testcases/documentation හි පිහිටා ඇත. Module:accel/grc/testcases/documentation]]. [සංස්කරණය]
- ප්රයෝජනවත් සබැඳි: root page • root page’s subpages • සබැඳි • transclusions • tested module • sandbox
1 of 0 tests failed. (refresh)
Text | Expected | Actual | |
---|---|---|---|
Script error during testing: Module:accel:92: bad argument #1 to 'ipairs' (table expected, got nil)stack traceback: [C]: ? [C]: in function 'ipairs' Module:accel:92: in function 'make_head' Module:accel:137: in function 'default_entry' Module:accel/grc/testcases:107: in function 'func' Module:UnitTests:295: in function 'iterate' Module:accel/grc/testcases:101: in function <Module:accel/grc/testcases:100> (tail call): ? [C]: in function 'xpcall' Module:UnitTests:369: in function <Module:UnitTests:328> (tail call): ? mw.lua:527: in function <mw.lua:507> [C]: ? [C]: in function 'expandTemplate' mw.lua:333: in function 'expandTemplate' Module:documentation:895: in function 'chunk' mw.lua:527: in function <mw.lua:507> [C]: ? |
local tests = require "Module:UnitTests"
local m_accel = require "Module:accel"
local m_grc_accel = require "Module:accel/grc"
local m_fun = require "Module:fun"
local m_table = require "Module:table"
local sorted_pairs = m_table.sortedPairs
local invert = m_table.invert
local grc = require "Module:languages".getByCode "grc"
local full_link = require "Module:links".full_link
local Array = require "Module:array"
local examples = {
{
{ target = "βελτῑ́ων", form = "comparative", pos = "adjective", origin = "ᾰ̓γᾰθός" },
{
pronunc = "{{grc-IPA|βελτῑ́ων}}",
pos_header = "Adjective",
head = "{{grc-adj-3rd|βελτῑ́ων|{{subst:chars|grc|βέλτῑον}}|deg=comp}}",
def = "{{comparative of|grc|ᾰ̓γᾰθός|nocat=1}}",
declension = "{{grc-adecl|βέλτῑον|deg=comp}}",
},
},
{
{ target = "βέλτῐστος", form = "superlative", pos = "adjective", origin = "ᾰ̓γᾰθός" },
{
pronunc = "{{grc-IPA|βέλτῐστος}}",
pos_header = "Adjective",
head = "{{grc-adj-1&2|βέλτῐστος|{{subst:chars|grc|βελτῐ́στη}}|{{subst:chars|grc|βέλτῐστον}}|deg=super}}",
def = "{{superlative of|grc|ᾰ̓γᾰθός|nocat=1}}",
declension = "{{grc-adecl|βέλτῐστος|βελτῐ́στη|deg=super}}",
},
},
{
{ target = "βεβηκώς", form = "m|perf|part", pos = "verb", origin = "βαίνω" },
{
pronunc = "{{grc-IPA}}",
pos_header = "Participle",
head = "{{grc-part-1&3|βεβηκυῖᾰ|βεβηκός}}",
def = "{{inflection of|grc|βαίνω||perf|part}}",
declension = "{{grc-adecl|βεβηκώς|βεβηκυῖᾰ}}",
},
},
{
{ target = "βεβηκυῖᾰ", form = "f|perf|part", pos = "verb", origin = "βαίνω" },
{
pronunc = "{{grc-IPA|βεβηκυῖᾰ}}",
pos_header = "Participle",
head = "{{grc-participle form|βεβηκυῖᾰ}}",
def = "{{inflection of|grc|βεβηκώς||f|nom|s}}",
},
},
}
-- So that fields in "entry" are displayed in the same order in which they will
-- appear in the resulting entry.
local param_order = m_table.invert {
"pronunc", "pos_header", "head", "def", -- entry
"inflection", "declension", "conjugation", "mutation"
}
local function compare_entry_params(param1, param2)
return param_order[param1] < param_order[param2]
end
local function format(entry)
local output = Array()
for k, v in sorted_pairs(entry, compare_entry_params) do
output:insert(k .. ": " .. mw.text.nowiki(v))
end
return mw.ustring.toNFC(output:concat "\n")
end
-- Put wikitext in code tags. Replace newlines with br tags.
local function display(entry_printed)
mw.log(entry_printed)
entry_printed = entry_printed:gsub("%f[^\n%z](.-: )([^\n]+)", "%1<code>%2</code>")
entry_printed = table.concat(
m_fun.map(
function (entry)
return '<p style="text-indent: -2em; margin: 0; padding-left: 2em;">'
.. entry .. '</p>'
end,
mw.text.split(entry_printed, "\n")))
return entry_printed
end
local function tag_and_link(word)
return full_link { lang = grc, term = word, tr = "-" }
end
-- Link origin and target.
local function show_params(params)
return ("%s (%s) → %s (<code>%s</code>)")
:format(tag_and_link(params.origin), params.pos,
tag_and_link(params.target), params.form)
end
local options = { display = display }
function tests:test()
self:iterate(
examples,
function (self, params, expected_entry)
params.lang = "grc"
params.target_pagename = (grc:makeEntryName(params.target))
local entry = m_accel.default_entry(params)
m_grc_accel.generate(params, entry)
mw.logObject(entry)
self:equals(show_params(params), format(entry), format(expected_entry),
options)
end)
end
return tests