Jump to content

Module:Params/testcases

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Grufo (talk | contribs) at 04:02, 31 January 2024 (Single-purpose helper subtemplates: New section). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

This is the testcases page for testing the behaviour of Module:Params.

As the module provides most of its functionalities only when called by templates, this page uses helper subtemplates to do its tests. You can find a list of these here.

General tests

Multi-purpose helper subtemplates

Helper subtemplate {{./multi}}

The {{./multi}} subtemplate allows to simulate in one single call both the incoming parameters and the parameters manually concatenated to {{#invoke:params|...|function|...}}, using a single hyphen (-) as a delimiter between the two groups. This allows to make general experiments directly from the preview window without having to edit separate templates.

For instance, writing

{{module:params/testcases/multi|
	setting|i/p|<br />|: |list|
	-|hello|world|foo=bar}}

will simulate a call with |1=hello, |2=world, and |foo=bar to a template whose content is {{#invoke:params|setting|i/p|<br />|: |list}}, thus producing:

Module:Params/testcases/multi

Single-purpose helper subtemplates

Helper subtemplate {{./tdelimiters}}

The {{./tdelimiters}} subtemplate allows to test the behaviour of delimiter strings between the arguments it was called with, invoking several functions of the module at once. For instance,

{{module:params/testcases/tdelimiters|foo|bar|Jupiter|hello=world}}

generates

list [HEADER][1=foo], [2=bar], [3=Jupiter] and [hello=world][FOOTER]
list_values [HEADER][foo], [bar], [Jupiter] and [world][FOOTER]
for_each [HEADER][1=foo], [2=bar], [3=Jupiter] and [hello=world][FOOTER]
call_for_each [HEADER][1=1][2=foo], [1=2][2=bar], [1=3][2=Jupiter] and [1=hello][2=world][FOOTER]
invoke_for_each [HEADER][1=1][2=foo], [1=2][2=bar], [1=3][2=Jupiter] and [1=hello][2=world][FOOTER]
magic_for_each [HEADER][foo], [bar], [Jupiter] and [world][FOOTER]
call_for_each_value [HEADER][1=foo], [1=bar], [1=Jupiter] and [1=world][FOOTER]
invoke_for_each_value [HEADER][1=foo], [1=bar], [1=Jupiter] and [1=world][FOOTER]
magic_for_each_value [HEADER][foo], [bar], [Jupiter] and [world][FOOTER]

Miscellaneous helper subtemplates

Helper subtemplate {{./print1}}

The {{./print1}} subtemplate only echoes the first unnamed parameter passed and discards the others (i.e. simply {{{1|}}}).

Testing single functions

Testing the list function

Helper subtemplate {{./echo}}

The {{./echo}} subtemplate calls the {{#invoke:params|list}} function to echo the code it was called with.

Example:

Markup Renders as
{{module:params/testcases/echo|hello|world|foo=bar}}

Dummies