Module:ArgRest/testcases: Difference between revisions
Appearance
Content deleted Content added
m made it a bit easier to read |
No edit summary |
||
Line 16: | Line 16: | ||
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1-a|c}}}{{{1-b}}}</nowiki>|1-a}}</nowiki>| 1-a=a | 1-b=b | 2-b=d }}', 'ab') |
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1-a|c}}}{{{1-b}}}</nowiki>|1-a}}</nowiki>| 1-a=a | 1-b=b | 2-b=d }}', 'ab') |
||
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1-a}}}{{{1-b}}}</nowiki>|1-a}}</nowiki>| 1-a=a | 1-b=b | 2-b=d | 3-a=e }}', 'ab') |
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1-a}}}{{{1-b}}}</nowiki>|1-a}}</nowiki>| 1-a=a | 1-b=b | 2-b=d | 3-a=e }}', 'ab') |
||
end |
|||
function p:test_outerHTML() |
|||
---- Test whether the module can handle being inside of HTML. There's nothing for outer templates; ArgRest ''cannot'' handle outer templates. |
|||
self:preprocess_equals('<b>' .. pre .. '<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1}}}</nowiki>|1}}</nowiki>|a|b|c}}' .. "</b>", '<b>abc</b>', {nowiki=1}) |
|||
end |
|||
function p:test_innerSyntax() |
|||
-- Functioning with HTML |
|||
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest|main|<nowiki><b>{{{1}}}</b></nowiki>|1}}</nowiki>|a|b|c}}', '<b>a</b><b>b</b><b>c</b>', {nowiki=1}) |
|||
-- Functioning with inner templates |
|||
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest|main|<nowiki>{{1x|{{{1}}}}}</nowiki>|1}}</nowiki>|a|b}}', 'ab') |
|||
end |
end |
||
Revision as of 00:03, 31 March 2023
![]() | This is the test cases page for the module Module:ArgRest. Results of the test cases. |
-- Unit tests for [[Module:{{ROOTPAGENAME}}]]. Click talk page to run tests.
local p = require('Module:UnitTests')
local pre = "{{#invoke:ArgRest/testCaser | main |sourceCode=" -- shortens this, just to make everything easier to read
function p:test_basicFunctioning()
-- Functioning with unnamed parameters
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1}}}</nowiki>|1}}</nowiki>|a|b|c}}', 'abc')
self:preprocess_equals(pre .. '<nowiki>a{{#invoke:ArgRest|main|<nowiki> + {{{1}}}</nowiki>|1}}</nowiki>|b|c|d}}', 'a + b + c + d')
self:preprocess_equals(pre .. '<nowiki>{{{1}}}{{#invoke:ArgRest|main|<nowiki> {{{2}}}</nowiki>|2}}</nowiki>|a|b|c}}', 'a b c')
-- Functioning with named parameters
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1-a}}}{{{1-b}}}</nowiki>|1-a}}</nowiki>| 1-a=a | 1-b=b | 2-a=c | 2-b=d }}', 'abcd')
self:preprocess_equals(pre .. '<nowiki>{{{1-a}}} - {{{1-b}}}{{#invoke:ArgRest|main|<nowiki> + {{{2-a}}} - {{{2-b}}}</nowiki>|2-a}}</nowiki>| 1-a=a | 1-b=b | 2-a=c | 2-b=d | 3-a=e | 3-b = f}}', 'a - b + c - d + e - f')
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1-a}}}{{{1-b|d}}}</nowiki>|1-a}}</nowiki>| 1-a=a | 1-b=b | 2-a=c }}', 'abcd')
-- Test determination not to move on if the "main" parameter was skipped
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1-a}}}{{{1-b}}}</nowiki>|1-a}}</nowiki>| 1-a=a | 1-b=b | 2-b=d }}', 'ab')
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1-a|c}}}{{{1-b}}}</nowiki>|1-a}}</nowiki>| 1-a=a | 1-b=b | 2-b=d }}', 'ab')
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1-a}}}{{{1-b}}}</nowiki>|1-a}}</nowiki>| 1-a=a | 1-b=b | 2-b=d | 3-a=e }}', 'ab')
end
function p:test_outerHTML()
---- Test whether the module can handle being inside of HTML. There's nothing for outer templates; ArgRest ''cannot'' handle outer templates.
self:preprocess_equals('<b>' .. pre .. '<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1}}}</nowiki>|1}}</nowiki>|a|b|c}}' .. "</b>", '<b>abc</b>', {nowiki=1})
end
function p:test_innerSyntax()
-- Functioning with HTML
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest|main|<nowiki><b>{{{1}}}</b></nowiki>|1}}</nowiki>|a|b|c}}', '<b>a</b><b>b</b><b>c</b>', {nowiki=1})
-- Functioning with inner templates
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest|main|<nowiki>{{1x|{{{1}}}}}</nowiki>|1}}</nowiki>|a|b}}', 'ab')
end
return p