Module:template parser/testcases
- පහත දැක්වෙන උපදෙස්, Module:template parser/testcases/documentation හි පිහිටා ඇත. [සංස්කරණය]
- ප්රයෝජනවත් සබැඳි: root page • root page’s subpages • සබැඳි • transclusions • tested module • sandbox
2 of 0 tests failed. (refresh)
Text | Expected | Actual | |
---|---|---|---|
Script error during testing: Module:table:557: attempt to call upvalue 'string_sort' (a nil value)stack traceback: [C]: in function 'string_sort' Module:table:557: in function <Module:table:550> [C]: in function 'sort' Module:table:578: in function 'keys_to_list' Module:table:594: in function 'sorted_pairs' Module:UnitTests:88: in function 'val_to_str' Module:UnitTests:85: in function 'val_to_str' Module:UnitTests:277: in function 'equals_deep' Module:template_parser/testcases:9: in function 'func' Module:UnitTests:295: in function 'iterate' ... [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:877: in function 'chunk' mw.lua:527: in function <mw.lua:507> [C]: ? |
Text | Expected | Actual | |
---|---|---|---|
Script error during testing: Module:table:557: attempt to call upvalue 'string_sort' (a nil value)stack traceback: [C]: in function 'string_sort' Module:table:557: in function <Module:table:550> [C]: in function 'sort' Module:table:578: in function 'keys_to_list' Module:table:594: in function 'sorted_pairs' Module:UnitTests:88: in function 'val_to_str' Module:UnitTests:85: in function 'val_to_str' Module:UnitTests:277: in function 'equals_deep' Module:template_parser/testcases:9: in function 'func' Module:UnitTests:295: in function 'iterate' ... [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:877: in function 'chunk' mw.lua:527: in function <mw.lua:507> [C]: ? |
local tests = require "Module:UnitTests"
local parse_template = require "Module:template parser".parseTemplate
local highlight = require "Module:debug".highlight { lang = "text" }
function tests:check_templates(examples)
local options = { nowiki = true }
tests:iterate(examples, function(self, wikitext, expected)
self:equals_deep(highlight(wikitext), {parse_template(wikitext)}, expected, options)
end)
end
function tests:test_basic()
local examples = {
{
"{{l|en|word}}",
{ "link", { "en", "word" } },
},
{
"{{t|cmn|大老二|tr={{m|cmn|dà lǎo èr}}}}",
{ "t", { "cmn", "大老二", tr = "{{m|cmn|dà lǎo èr}}" } },
},
{
"{{t|akk|𒁀|tr=[[Image:B014ellst.png|30px]] qiāšu, BA}}",
{ "t", { "akk", "𒁀", tr = "[[Image:B014ellst.png|30px]] qiāšu, BA" } },
}
}
self:check_templates(examples)
end
function tests:test_whitespace()
self:check_templates {
{ "{{l| en | word\n}}", { "link", { " en ", " word\n" } } },
{ "{{l| en | 2 = word\n}}", { "link", { " en ", "word" } } },
{ "{{l| 1 = en | word\n}}", { "link", { " word\n" } } },
}
end
return tests