Module:template parser/testcases

Hello, you have come here looking for the meaning of the word Module:template parser/testcases. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:template parser/testcases, but we will also tell you about its etymology, its characteristics and you will know how to say Module:template parser/testcases in singular and plural. Everything you need to know about the word Module:template parser/testcases you have here. The definition of the word Module:template parser/testcases will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:template parser/testcases, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

2 of 0 tests failed. (refresh)

TextExpectedActual
test_basic:
Script error during testing: Module:template_parser/testcases:10: attempt to call method 'get_name' (a nil value)
stack traceback:
	: in function 'get_name'
	Module:template_parser/testcases:10: in function 'func'
	Module:UnitTests:313: in function 'iterate'
	Module:template_parser/testcases:8: in function 'check_templates'
	Module:template_parser/testcases:38: in function <Module:template_parser/testcases:14>
	(tail call): ?
	(tail call): ?
	: in function 'xpcall'
	Module:fun/xpcall:37: in function 'xpcall'
	Module:UnitTests:389: in function <Module:UnitTests:350>
	(tail call): ?
	mw.lua:527: in function <mw.lua:507>
	: ?
	: in function 'expandTemplate'
	mw.lua:333: in function <mw.lua:307>
	(tail call): ?
	(tail call): ?
	Module:documentation:1026: in function 'chunk'
	mw.lua:527: in function <mw.lua:507>
	: ?
TextExpectedActual
test_whitespace:
Script error during testing: Module:template_parser/testcases:10: attempt to call method 'get_name' (a nil value)
stack traceback:
	: in function 'get_name'
	Module:template_parser/testcases:10: in function 'func'
	Module:UnitTests:313: in function 'iterate'
	Module:template_parser/testcases:8: in function 'check_templates'
	Module:template_parser/testcases:42: in function <Module:template_parser/testcases:41>
	(tail call): ?
	(tail call): ?
	: in function 'xpcall'
	Module:fun/xpcall:37: in function 'xpcall'
	Module:UnitTests:389: in function <Module:UnitTests:350>
	(tail call): ?
	mw.lua:527: in function <mw.lua:507>
	: ?
	: in function 'expandTemplate'
	mw.lua:333: in function <mw.lua:307>
	(tail call): ?
	(tail call): ?
	Module:documentation:1026: in function 'chunk'
	mw.lua:527: in function <mw.lua:507>
	: ?

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=] qiāšu, BA}}",
			{ "t", { "akk", "𒁀", tr = "] qiāšu, BA" } },
		}
	}
	local frame = mw.getCurrentFrame()
	for i, example in ipairs(examples) do
		local args, new = example, {}
		for k, v in pairs(args) do
			k = type(k) == "string" and frame:preprocess(k) or k
			new = frame:preprocess(v)
		end
		example = 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