Module:Params/testcases: Difference between revisions
Updates |
|||
| (14 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
[[File:Gelemental.svg|thumb|Here are some tools for testing {{ml|params|}} and [[Module:Params/sandbox|its sandbox version]].]] |
[[File:Gelemental.svg|thumb|Here are some tools for testing {{ml|params|}} and [[Module:Params/sandbox|its sandbox version]].]] |
||
| ⚫ | |||
This is the [[Wikipedia:Template sandbox and test cases|testcases]] page for checking the behaviour of [[Module:Params]]. |
This is the [[Wikipedia:Template sandbox and test cases|testcases]] page for checking 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 [[Special:PrefixIndex/Module:Params/testcases/|here]]. Several helper subtemplates come in two versions, one that depends on {{ml|params|}} and one that depends on {{ml|params/sandbox|}}. Example templates, used by the documentation page, are available at [[Module:Params/doc/examples|/doc/examples]]. |
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 [[Special:PrefixIndex/Module:Params/testcases/|here]]. Several helper subtemplates come in two versions, one that depends on {{ml|params|}} and one that depends on {{ml|params/sandbox|}}. Example templates, used by the documentation page, are available at [[Module:Params/doc/examples|/doc/examples]]. |
||
{{module:params/doc/sandboxes |
|||
| Module:Params/testcases/sandbox |
|||
| Module:Params/testcases/sandbox2 |
|||
| Module:Params/testcases/sandbox3 |
|||
| Module:Params/testcases/sandbox4 |
|||
| Module:Params/testcases/sandbox5 |
|||
}} |
|||
== General tests == |
== General tests == |
||
| ⚫ | |||
=== Multi-purpose helper subtemplates === |
|||
==== Helper subtemplate {{[[Module:Params/testcases/tmulti|./tmulti]]}} ==== |
|||
The {{[[Module:Params/testcases/tmulti|./tmulti]]}} subtemplate allows to simulate in one single call both the incoming parameters and the parameters manually concatenated to <code>{{ml|params|...|''function''|...}}</code>, using a single hyphen (<code>-</code>) 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 |
|||
<syntaxhighlight lang="wikitext">{{module:params/testcases/tmulti| |
|||
setting|i/p|<br />|: |list| |
|||
-|hello|world|foo=bar}}</syntaxhighlight> |
|||
will simulate a call with {{para|1|hello}}, {{para|2|world}}, and {{para|foo|bar}} to a template whose content is <syntaxhighlight lang="wikitext" inline>{{#invoke:params|setting|i/p|<br />|: |list}}</syntaxhighlight>, thus producing: |
|||
| ⚫ | |||
setting|i/p|<br />|: |list| |
|||
-|hello|world|foo=bar}} |
|||
| ⚫ | |||
=== Single-purpose helper subtemplates === |
|||
| ⚫ | |||
The {{[[Module:Params/testcases/tdelimiters|./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, |
The {{[[Module:Params/testcases/tdelimiters|./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, |
||
| Line 39: | Line 27: | ||
{{A note}} An identical subtemplate that uses [[Module:Params/sandbox]] instead of [[Module:Params]] is available at {{[[Module:Params/testcases/tdelimiters sandbox|./tdelimiters sandbox]]}}. |
{{A note}} An identical subtemplate that uses [[Module:Params/sandbox]] instead of [[Module:Params]] is available at {{[[Module:Params/testcases/tdelimiters sandbox|./tdelimiters sandbox]]}}. |
||
=== Helper subtemplate {{[[Module:Params/testcases/tnumerical|./tnumerical]]}} === |
|||
The {{[[Module:Params/testcases/tnumerical|./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 {{para|#first}} and {{para|#second}} special parameters to do its tests. For instance, |
The {{[[Module:Params/testcases/tnumerical|./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 {{para|#first}} and {{para|#second}} special parameters to do its tests. For instance, |
||
| Line 70: | Line 58: | ||
{{A note}} An identical subtemplate that uses [[Module:Params/sandbox]] instead of [[Module:Params]] is available at {{[[Module:Params/testcases/tnumerical sandbox|./tnumerical sandbox]]}}. |
{{A note}} An identical subtemplate that uses [[Module:Params/sandbox]] instead of [[Module:Params]] is available at {{[[Module:Params/testcases/tnumerical sandbox|./tnumerical sandbox]]}}. |
||
=== Helper subtemplate {{[[Module:Params/testcases/tmaps|./tmaps]]}} === |
|||
The {{[[Module:Params/testcases/tmaps|./tmaps]]}} subtemplate allows to test the behaviour of all the <code>mapping_*</code> and <code>renaming_*</code> class of modifiers. As the template generates a very large page its expansion is not shown here. For more information please visit its documentation page. |
The {{[[Module:Params/testcases/tmaps|./tmaps]]}} subtemplate allows to test the behaviour of all the <code>mapping_*</code> and <code>renaming_*</code> class of modifiers. As the template generates a very large page its expansion is not shown here. For more information please visit its documentation page. |
||
{{A note}} An identical subtemplate that uses [[Module:Params/sandbox]] instead of [[Module:Params]] is available at {{[[Module:Params/testcases/tmaps sandbox|./tmaps sandbox]]}}. |
{{A note}} An identical subtemplate that uses [[Module:Params/sandbox]] instead of [[Module:Params]] is available at {{[[Module:Params/testcases/tmaps sandbox|./tmaps sandbox]]}}. |
||
=== Helper subtemplate {{[[Module:Params/testcases/tcompare separated entries|./tcompare separated entries]]}} === |
|||
The {{[[Module:Params/testcases/tcompare separated entries|./tcompare separated entries]]}} subtemplate compares the behaviours of [[Module:Params]] with that of [[Module:Separated entries]]. For instance, |
The {{[[Module:Params/testcases/tcompare separated entries|./tcompare separated entries]]}} subtemplate compares the behaviours of [[Module:Params]] with that of [[Module:Separated entries]]. For instance, |
||
| Line 83: | Line 71: | ||
{{ module:params/testcases/tcompare separated entries | one | two | three | foo | bar | Jupiter | hello = world }} |
{{ module:params/testcases/tcompare separated entries | one | two | three | foo | bar | Jupiter | hello = world }} |
||
==== Helper subtemplate {{[[Module:Params/testcases/tcoins|./tcoins]]}} ==== |
|||
The {{[[Module:Params/testcases/tcoins|./tcoins]]}} subtemplate allows to experiment with the <code>[[Module:Params#coins|coins]]</code> and <code>[[Module:Params#unique_coins|unique_coins]]</code> functions, which are called with the following arguments: <syntaxhighlight lang="wikitext" inline>one|two|three|foo=bar|hello=world</syntaxhighlight>. Therefore, transcluding the template with, |
|||
<syntaxhighlight lang="wikitext">{{Module:Params/testcases/tcoins|foo|hello|2|3|foo}}</syntaxhighlight> |
|||
generates |
|||
{{module:params/testcases/tcoins|foo|hello|2|3|foo}} |
|||
{{A note}} An identical subtemplate that uses [[Module:Params/sandbox]] instead of [[Module:Params]] is available at {{[[Module:Params/testcases/tcoins sandbox|./tcoins sandbox]]}}. |
|||
== Testing individual functions == |
== Testing individual functions == |
||
=== |
=== Helper subtemplate {{[[Module:Params/testcases/techo|./techo]]}} === |
||
==== Helper subtemplate {{[[Module:Params/testcases/techo|./techo]]}} ==== |
|||
The {{[[Module:Params/testcases/techo|./techo]]}} subtemplate calls the {{mfl|params|list}} function to echo the code it was called with. |
The {{[[Module:Params/testcases/techo|./techo]]}} subtemplate calls the {{mfl|params|list}} function to echo the code it was called with. |
||
| Line 111: | Line 86: | ||
* Dummy subtemplates |
* Dummy subtemplates |
||
** {{[[module:params/testcases/tdummy echo sb]]}} |
** {{[[module:params/testcases/tdummy echo sb]]}} |
||
== Deprecated tools == |
|||
The following tools were developed with older versions of [[Module:Params]] in mind, and were later superseded by new functionalities in the module. They are kept here for historical reasons. |
|||
| ⚫ | |||
* {{[[Module:Params/testcases/tcoins|./tcoins]]}} and {{[[Module:Params/testcases/tcoins sandbox|./tcoins sandbox]]}} – no longer functional since the [[Module:Params/ChangeLog#15th June 2026|†]] <code>coins</code> and [[Module:Params/ChangeLog#13th July 2026|†]] <code>unique_coins</code> functions have been deleted from the module |
|||
== See also == |
== See also == |
||
* [[Module:Params/ChangeLog|ChangeLog of Module:Params]] |
* [[Module:Params/ChangeLog|ChangeLog of Module:Params]] |
||
* |
* [[Module:Params/doc/examples|../doc/examples]] |
||
* {{Internal link with parameters | Special:Search | Extensive “in source” search |
|||
* <span class="plainlinks">[//en.wikipedia.org/w/index.php?title=Special:Search&search=insource%3A%2Finvoke%3Aparams%2F&limit=500&offset=0&ns0=1&ns1=1&ns2=1&ns3=1&ns4=1&ns5=1&ns6=1&ns7=1&ns8=1&ns9=1&ns10=1&ns11=1&ns12=1&ns13=1&ns14=1&ns15=1&ns100=1&ns101=1&ns118=1&ns119=1&ns710=1&ns711=1&ns829=1&sort=last_edit_desc Extensive “in source” search]</span>. |
|||
| search = insource:/invoke:params/i |
|||
| limit = 500 |
|||
| offset = 0 |
|||
| ns0 = 1 |
|||
| ns1 = 1 |
|||
| ns2 = 1 |
|||
| ns3 = 1 |
|||
| ns4 = 1 |
|||
| ns5 = 1 |
|||
| ns6 = 1 |
|||
| ns7 = 1 |
|||
| ns8 = 1 |
|||
| ns9 = 1 |
|||
| ns10 = 1 |
|||
| ns11 = 1 |
|||
| ns12 = 1 |
|||
| ns13 = 1 |
|||
| ns14 = 1 |
|||
| ns15 = 1 |
|||
| ns100 = 1 |
|||
| ns101 = 1 |
|||
| ns118 = 1 |
|||
| ns119 = 1 |
|||
| ns710 = 1 |
|||
| ns711 = 1 |
|||
| ns829 = 1 |
|||
| sort = last_edit_desc |
|||
}} |
|||
** {{sl|all: contentmodel:wikitext hastemplate:module:params insource:"#invoke:params{{!}}" insource:/\#invoke *: *params *\{{!}}/i|Alternative search including in the <code>Module:</code> namespace|limit=500}} |
|||
[[Category:Module test cases]] |
[[Category:Module test cases]] |
||
Latest revision as of 22:09, 13 July 2026

This is the testcases page for checking 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. Several helper subtemplates come in two versions, one that depends on {{#invoke:params|function}} and one that depends on {{#invoke:params/sandbox|function}}. Example templates, used by the documentation page, are available at /doc/examples.
There are a few sandbox subpages that you can freely use to experiment with new testcases for {{#invoke:params}} at Module:Params/testcases/sandbox, Module:Params/testcases/sandbox2, Module:Params/testcases/sandbox3, Module:Params/testcases/sandbox4 and Module:Params/testcases/sandbox5. In order to avoid possible conflicts with other editors, we suggest you use the one with the oldest last edit, which currently is Module:Params/testcases/sandbox5 ().
General tests
[edit source]Helper subtemplate {{./tdelimiters}}
[edit source]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] |
Template:A note An identical subtemplate that uses Module:Params/sandbox instead of Module:Params is available at {{./tdelimiters sandbox}}.
Helper subtemplate {{./tnumerical}}
[edit source]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
|
|---|---|
squeezing
|
|1=minus two|2=zero|3=one|4=two|5=three|6=nineteen|7=twenty |
filling_the_gaps
|
|-2=minus two|-1=|0=zero|1=one|2=two|3=three|4=|5=|6=|7=|8=|9=|10=|11=|12=|13=|14=|15=|16=|17=|18=|19=nineteen|20=twenty |
clearing
|
|1=one|2=two|3=three |
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_numeric_names
|
|1=twenty|2=nineteen|18=three|19=two|20=one|21=zero|23=minus two |
sorting_sequential_values
|
|-2=minus two|0=zero|1=one|2=three|3=two|19=nineteen|20=twenty |
Template:A note An identical subtemplate that uses Module:Params/sandbox instead of Module:Params is available at {{./tnumerical sandbox}}.
Helper subtemplate {{./tmaps}}
[edit source]The {{./tmaps}} subtemplate allows to test the behaviour of all the mapping_* and renaming_* class of modifiers. As the template generates a very large page its expansion is not shown here. For more information please visit its documentation page.
Template:A note An identical subtemplate that uses Module:Params/sandbox instead of Module:Params is available at {{./tmaps sandbox}}.
Helper subtemplate {{./tcompare separated entries}}
[edit source]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 |
Testing individual functions
[edit source]Helper subtemplate {{./techo}}
[edit source]The {{./techo}} subtemplate calls the {{#invoke:params|list}} function to echo the code it was called with.
Example:
Dummies
[edit source]- Dummy submodules
- Dummy subtemplates
Deprecated tools
[edit source]The following tools were developed with older versions of Module:Params in mind, and were later superseded by new functionalities in the module. They are kept here for historical reasons.
- {{./tmulti}} and {{./tmulti sandbox}}
- {{./tcoins}} and {{./tcoins sandbox}} – no longer functional since the †
coinsand †unique_coinsfunctions have been deleted from the module