All tests passed. (refresh)

TextExpectedActual
test_basic:
Passed
{{l|en|word}}
{"link", {"en", "word"}}{"link", {"en", "word"}}
Passed
{{t|cmn|大老二|tr={{m|cmn|dà lǎo èr}}}}
{"t", {"cmn", "大老二", tr='<i class="Latn mention" lang="cmn">[[dà lǎo èr#මැන්ඩරීන්|dà lǎo èr]]</i>'}}{"t", {"cmn", "大老二", tr='<i class="Latn mention" lang="cmn">[[dà lǎo èr#මැන්ඩරීන්|dà lǎo èr]]</i>'}}
Passed
{{t|akk|𒁀|tr=[[Image:B014ellst.png|30px]] qiāšu, BA}}
{"t", {"akk", "𒁀", tr="[[Image:B014ellst.png|30px]] qiāšu, BA"}}{"t", {"akk", "𒁀", tr="[[Image:B014ellst.png|30px]] qiāšu, BA"}}
TextExpectedActual
test_whitespace:
Passed
{{l| en | word
}}
{"link", {" en ", " word\n"}}{"link", {" en ", " word\n"}}
Passed
{{l| en | 2 = word
}}
{"link", {" en ", "word"}}{"link", {" en ", "word"}}
Passed
{{l| 1 = en | word
}}
{"link", {" word\n"}}{"link", {" word\n"}}

local tests = require "Module:UnitTests"

local highlight = require("Module:debug").highlight{ lang = "text"}
local parse = require("Module:template parser").parse

function tests:check_templates(examples)
	local options = { nowiki = true }
	tests:iterate(examples, function(self, wikitext, expected)
		local template = parse(wikitext)
		self:equals_deep(highlight(wikitext), {template:get_name(), template:get_arguments()}, 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" } },
		}
	}
	local frame = mw.getCurrentFrame()
	for i, example in ipairs(examples) do
		local args, new = example[2][2], {}
		for k, v in pairs(args) do
			k = type(k) == "string" and frame:preprocess(k) or k
			new[k] = frame:preprocess(v)
		end
		example[2][2] = new
	end
	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
"https://si.wiktionary.org/w/index.php?title=Module:template_parser/testcases&oldid=193453" වෙතින් සම්ප්‍රවේශනය කෙරිණි