Difference between revisions of "Category talk:Template test case/doc"

From blackwiki
Jump to navigation Jump to search
blackwiki>Mr. Stradivarius
(add usage from wikitext)
 
blackwiki>Mr. Stradivarius
(add basics of Lua usage)
Line 17: Line 17:
  
 
It is also possible to use a format of <code><nowiki>{{#invoke:template test case|main|</nowiki>''parameters''<nowiki>}}</nowiki></code>. This uses the same defaults as [[Template:Test case]]; please see that page for documentation of the parameters.
 
It is also possible to use a format of <code><nowiki>{{#invoke:template test case|main|</nowiki>''parameters''<nowiki>}}</nowiki></code>. This uses the same defaults as [[Template:Test case]]; please see that page for documentation of the parameters.
 +
 +
=== From Lua ===
 +
 +
First, load the module:
 +
<source lang="lua">
 +
local mTestCase = require('Module:Template test case')
 +
</source>
 +
 +
You can then use one of the functions listed below.
 +
 +
==== Table function ====
 +
 +
<source lang="lua">
 +
mTestCase.table(args, cfg)
 +
</source>
 +
 +
==== Nowiki function ====
 +
 +
<source lang="lua">
 +
mTestCase.nowiki(args, cfg)
 +
</source>
  
 
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
 
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||

Revision as of 23:48, 30 November 2014

This module provides a framework for making templates which produce a template test case. While test cases can be made manually, using Lua-based templates such as the ones provided by this module has the advantage that the template arguments only need to be input once, thus reducing the effort involved in making test cases and reducing the possibility of errors in the input.

Usage

From wikitext

This module should not usually be called directly. Instead, you should use one of the following templates:

Parameter-based templates:

The only difference between these templates is their default arguments. For example, it is possible to display test cases side by side in Template:Testcase rows by specifying |_format=columns

Nowiki-based templates:

  • Template:Test case nowiki - for test cases created from template code wrapped in nowiki tags (useful for displaying templates with many parameters)

It is also possible to use a format of {{#invoke:template test case|main|parameters}}. This uses the same defaults as Template:Test case; please see that page for documentation of the parameters.

From Lua

First, load the module:

local mTestCase = require('Module:Template test case')

You can then use one of the functions listed below.

Table function

mTestCase.table(args, cfg)

Nowiki function

mTestCase.nowiki(args, cfg)