Module:Template test case
Documentation for this module may be created at Module:Template test case/doc
-- This module provides several methods to generate test cases.
local libraryUtil = require('libraryUtil')
local checkTypeForNamedArg = libraryUtil.checkTypeForNamedArg
--------------------------------------------------------------------------------
-- Test case display functions
--
-- Test case display functions produce the wikitext to display the template
-- output for one test case. For example, one function might produce templates
-- aligned horizontally, and another function might produce templates aligned
-- one below the other.
--
-- They are named functions that accept the following parameters:
-- * templates - an array of subtables containing data about each template to be
-- displayed. These subtables can contain the following values:
-- * result - the expanded wikitext from the template.
-- * invocation - the original unexpanded wikitext that the output was
-- generated from. This may be nil if the invocation is not available.
-- * name - the name of the template.
-- * link - a normal wikilink to the template page (displays as
-- "Template:Foo").
-- * braceLink - a wikilink to the template page formatted like the {{tl}}
-- template, i.e. it displays as "{{Foo}}".
-- * heading - a heading to display above the template output.
--------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- TestCase class
-------------------------------------------------------------------------------
local TestCase = {}
TestCase.__index = TestCase
function TestCase.new(t)
-- Validate the input
checkTypeForNamedArg('TestCase.new', 'invocation', t.invocation, 'table')
checkTypeForNamedArg('TestCase.new', 'templates', t.templates, 'table')
checkTypeForNamedArg('TestCase.new', 'options', t.options, 'table', true)
t.options = t.options or {}
local obj = setmetatable({}, TestCase)
return obj
end