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 complete list of these here. Example templates, used by the documentation page, are available at /doc/examples.

General tests edit

Multi-purpose helper subtemplates edit

Helper subtemplate {{./tmulti}} edit

The {{./tmulti}} 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/tmulti|
	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:

1: hello
2: world
foo: bar

Single-purpose helper subtemplates edit

Helper subtemplate {{./tdelimiters}} edit

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]

Helper subtemplate {{./tnumerical}} edit

The {{./tnumerical}} subtemplate allows to test the behaviour of functions that focus on numerical and sequential arguments. As these require at most two arguments, the template uses the |#first= and |#second= special parameters to do its tests. For instance,

{{module:params/testcases/tnumerical
	| #first = 2
	| #second = 2
	| -2 = minus two
	| 0 = zero
	| 1 = one
	| 2 = two
	| 3 = three
	| 19 = nineteen
	| 20 = twenty
}}

generates

Function name Result for |#first=2 and |#second=2
cutting|2{2]|... |-2=minus two|0=zero|16=nineteen|17=twenty
cropping|2{2|... |0=zero|1=one|2=two|3=three
purging|2{2|... |-2=minus two|0=zero|1=one|17=nineteen|18=twenty
backpurging|2{2|... |-2=minus two|0=zero|1=three|17=nineteen|18=twenty
reversing |-2=twenty|-1=nineteen|15=three|16=two|17=one|18=zero|20=minus two
mirroring |-16=twenty|-15=nineteen|1=three|2=two|3=one|4=zero|6=minus two

Helper subtemplate {{./tcompare separated entries}} edit

The {{./tcompare separated entries}} subtemplate compares the behaviours of Module:Params with that of Module:Separated entries. For instance,

{{ module:params/testcases/tcompare separated entries | one | two | three | foo  | bar | Jupiter | hello = world }}

generates

Without a last separator:

{{#invoke:separated entries|main|separator=+}}

one+two+three+foo+bar+Jupiter

{{#invoke:params|sequential|squeezing|trimming_values|setting|i|+|list_values}}

one+two+three+foo+bar+Jupiter

With a last separator (::):

{{#invoke:params|sequential|squeezing|trimming_values|setting|i/l|+|::|list_values}}

one+two+three+foo+bar::Jupiter

{{#invoke:separated entries|main|separator=+|conjunction=::}}

one+two+three+foo+bar::Jupiter

With a last separator (::) and cutting the first three parameters:

{{#invoke:params|sequential|cutting|3|0|squeezing|trimming_values|setting|i/l|+|::|list_values}}

foo+bar::Jupiter

{{#invoke:separated entries|main|separator=+|conjunction=::|start=4}}

foo+bar::Jupiter

Miscellaneous helper subtemplates edit

Helper subtemplate {{./tprint1}} edit

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

Testing single functions edit

Testing the list function edit

Helper subtemplate {{./techo}} edit

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

Example:

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

{{Module:Params/testcases/techo|1=hello|2=world|foo=bar}}

Dummies edit

See also edit