User:Lemondoge/moduletest
This is a testing template for Module:ArgRest. Due to ArgRest's nature of reading the parameters of its parent (which it thinks is a transcluded template) as well as its own, it is difficult to create a Lua /testcases
page for it without the use of a proxy template. Until a way to create a testcases page without using a template is found, this template and its documentation serves as a temporary substitute for one.
Usage
[edit]This template has five test configurations, chosen via {{{testType}}}
. Whether to use Module:ArgRest or Module:ArgRest/sandbox is selected via {{{useSandbox}}}
.
A list of test types, and their corresponding wikitext source code, is below:
unnamedParameters
, for testing, well, unnamed parameters:
{{#invoke:ArgRest{{#if:{{yesno|{{{useSandbox|}}}}}|/sandbox}}|main|<nowiki>{{{1}}},</nowiki>|1}}
userboxList
, for testing ArgRest's ability to handle inner wikitext:
{{#invoke:ArgRest{{#if:{{yesno|{{{useSandbox|}}}}}|/sandbox}}|main|<nowiki>{{Userbox|id=<span style="color: blue">{{{1a}}}</span>|info='''{{{1b}}}'''|nocat=true}}</nowiki>|1a}}
enumerate
, for testing ArgRest's ability to handle being inside of a template, and "summoning" parameters for said template.
{{Enum{{#invoke:ArgRest{{#if:{{yesno|{{{useSandbox|}}}}}|/sandbox}}|main|<nowiki>|{{{1a}}}</nowiki>|1a}}}}
defaults
, for testing functionality with default values:
{{#invoke:ArgRest{{#if:{{yesno|{{{useSandbox|}}}}}|/sandbox}}|main|<nowiki>{{{1-a}}}, {{{1-b|defaulted b parameter}}}, {{{1-c}}}, </nowiki>|1-a}}
start
, for testing its ability to start at numbers higher than 1:
{{#invoke:ArgRest{{#if:{{yesno|{{{useSandbox|}}}}}|/sandbox}}|main| + {{{2a}}}|2a}}}}
Demos
[edit]unnamedParameters
[edit]Expected output: parameter1,parameter2,parameter3,
{{User:Lemondoge/moduletest|testType=unnamedParameters|parameter1|parameter2|parameter3}}
sandbox:
{{User:Lemondoge/moduletest|testType=unnamedParameters|useSandbox=yes|parameter1|parameter2|parameter3}}
userboxList
[edit]{{User:Lemondoge/moduletest|testType=userboxList|1a=a; 1|1b=Lorem|2a=b; 2|2b=ipsum|3a=c; 3|3b=dolor,|4a=d; 4|4b=sit amet}}
a; 1 | Lorem |
b; 2 | ipsum |
c; 3 | dolor, |
d; 4 | sit amet |
sandbox:
{{User:Lemondoge/moduletest|testType=userboxList|useSandbox=yes|1a=a; 1|1b=Lorem|2a=b; 2|2b=ipsum|3a=c; 3|3b=dolor,|4a=d; 4|4b=sit amet}}
a; 1 | Lorem |
b; 2 | ipsum |
c; 3 | dolor, |
d; 4 | sit amet |
enumerate
[edit]{{User:Lemondoge/moduletest|testType=enumerate|parameter1|parameter2|parameter3}}
sandbox:
{{User:Lemondoge/moduletest|testType=enumerate|useSandbox=yes|parameter1|parameter2|parameter3}}
defaults
[edit]Expected output: parameter 1-a, nondefaulted parameter 1-b, parameter 1-c, parameter 2-a, defaulted b parameter, {{{1-c}}},
{{User:Lemondoge/moduletest|testType=defaults|1-a=parameter 1-a|1-b=nondefaulted parameter 1-b|1-c=parameter 1-c|2-a=parameter 2-a}}
sandbox:
{{User:Lemondoge/moduletest|testType=defaults|useSandbox=yes|1-a=parameter 1-a|1-b=nondefaulted parameter 1-b|1-c=parameter 1-c|2-a=parameter 2-a}}
start
[edit]Expected output: parameter1 + parameter2 + parameter3 + parameter4
{{User:Lemondoge/moduletest|testType=start|1a=parameter1|2a=parameter2|3a=parameter3|4a=parameter4}}
sandbox:
{{User:Lemondoge/moduletest|testType=start|useSandbox=yes|1a=parameter1|2a=parameter2|3a=parameter3|4a=parameter4}}