Module:ArgRest/testcases explained

-- Unit tests for . Click talk page to run tests.local p = require('Module:UnitTests')

local pre = "}', 'abcd') self:preprocess_equals(pre .. '{{{1-a}}} - {{{1-b}}}{{#invoke:ArgRest|main|<nowiki> + {{{2-a}}} - {{{2-b}}}&lt;/nowiki>|2-a}}| 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 .. '{{#invoke:ArgRest|main|<nowiki>{{{1-a}}}{{{1-b|d}}}&lt;/nowiki>|1-a}}| 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 .. '{{#invoke:ArgRest|main|<nowiki>{{{1-a}}}{{{1-b}}}&lt;/nowiki>|1-a}}| 1-a=a | 1-b=b | 2-b=d }}', 'ab') self:preprocess_equals(pre .. '{{#invoke:ArgRest|main|<nowiki>{{{1-a|c}}}{{{1-b}}}&lt;/nowiki>|1-a}}| 1-a=a | 1-b=b | 2-b=d }}', 'ab') self:preprocess_equals(pre .. '{{#invoke:ArgRest|main|<nowiki>{{{1-a}}}{{{1-b}}}&lt;/nowiki>|1-a}}| 1-a=a | 1-b=b | 2-b=d | 3-a=e }}', 'ab') -- Empty defaults, and lack of defaults self:preprocess_equals(pre .. '{{#invoke:ArgRest|main|<nowiki>{{{1-a}}}{{{1-b|}}}&lt;/nowiki>|1-a}}| 1-a=a | 1-b=b | 2-a=c }}', 'abc') self:preprocess_equals(pre .. '{{#invoke:ArgRest|main|<nowiki>{{{1-a}}}{{{1-b}}}&lt;/nowiki>|1-a}}| 1-a=a | 1-b=b | 2-a=c }}', 'abc')endfunction p:test_outerSyntax ---- Test whether the module can handle being inside of HTML. self:preprocess_equals('' .. pre .. '{{#invoke:ArgRest|main|<nowiki>{{{1}}}&lt;/nowiki>|1}}|a|b|c}}' .. "", 'abc',) ---- Test whether the module can handle being inside of templates. self:preprocess_equals('' .. "}}", "") self:preprocess_equals_preprocess('' .. "final}}", "")endfunction p:test_innerSyntax -- Functioning with HTML self:preprocess_equals(pre .. '{{#invoke:ArgRest|main|<nowiki><b>{{{1}}}</b>&lt;/nowiki>|1}}|a|b|c}}', 'abc',) -- Functioning with inner templates self:preprocess_equals(pre .. '{{#invoke:ArgRest|main|<nowiki>{{1x|{{{1}}}}}&lt;/nowiki>|1}}|a|b}}', 'ab') self:preprocess_equals(pre .. '{{#invoke:ArgRest|main|<nowiki>{{enum|{{{1-a}}}|{{{1-b}}}}}&lt;/nowiki>|1-a}}|1-a=a|1-b=b|2-a=c|2-b=d}}', 'a and bc and d')end-- Sandbox variantsfunction p:test_sandboxBasicFunctioning -- Functioning with unnamed parameters self:preprocess_equals(pre .. '{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1}}}&lt;/nowiki>|1}}|a|b|c}}', 'abc') self:preprocess_equals(pre .. 'a{{#invoke:ArgRest/sandbox|main|<nowiki> + {{{1}}}&lt;/nowiki>|1}}|b|c|d}}', 'a + b + c + d') self:preprocess_equals(pre .. '{{{1}}}{{#invoke:ArgRest/sandbox|main|<nowiki> {{{2}}}&lt;/nowiki>|2}}|a|b|c}}', 'a b c') -- Functioning with named parameters self:preprocess_equals(pre .. '{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1-a}}}{{{1-b}}}&lt;/nowiki>|1-a}}| 1-a=a | 1-b=b | 2-a=c | 2-b=d }}', 'abcd') self:preprocess_equals(pre .. '{{{1-a}}} - {{{1-b}}}{{#invoke:ArgRest/sandbox|main|<nowiki> + {{{2-a}}} - {{{2-b}}}&lt;/nowiki>|2-a}}| 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 .. '{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1-a}}}{{{1-b|d}}}&lt;/nowiki>|1-a}}| 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 .. '{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1-a}}}{{{1-b}}}&lt;/nowiki>|1-a}}| 1-a=a | 1-b=b | 2-b=d }}', 'ab') self:preprocess_equals(pre .. '{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1-a|c}}}{{{1-b}}}&lt;/nowiki>|1-a}}| 1-a=a | 1-b=b | 2-b=d }}', 'ab') self:preprocess_equals(pre .. '{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1-a}}}{{{1-b}}}&lt;/nowiki>|1-a}}| 1-a=a | 1-b=b | 2-b=d | 3-a=e }}', 'ab') -- Empty defaults, and lack of defaults self:preprocess_equals(pre .. '{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1-a}}}{{{1-b|}}}&lt;/nowiki>|1-a}}| 1-a=a | 1-b=b | 2-a=c }}', 'abc') self:preprocess_equals(pre .. '{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1-a}}}{{{1-b}}}&lt;/nowiki>|1-a}}| 1-a=a | 1-b=b | 2-a=c }}', 'abc') -- Aliases self:preprocess_equals(pre .. '{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1-a|{{{1-b}}}}}}&lt;/nowiki>|1-a}}| 1-a=a | 2-a=b | 3-b=c }}', 'abc') self:preprocess_equals(pre .. '{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1-a|{{{1-b}}}}}}&lt;/nowiki>|1-a}}| 1-b=a | 2-b=b | 3-b=c }}', 'abc') self:preprocess_equals(pre .. '{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1-a}}}{{{1-b|{{{1-c}}}}}}&lt;/nowiki>|1-a}}| 1-a=a | 1-b=b | 2-a=c | 2-c=d }}', 'abcd') self:preprocess_equals(pre .. '{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1-a}}}{{{1-b|{{{1-c}}}}}}&lt;/nowiki>|1-a}}| 1-a=a | 1-b=b | 2-a=c }}', 'abc') self:preprocess_equals(pre .. '{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1-a}}}{{{1-b|{{{1-c|d}}}}}}&lt;/nowiki>|1-a}}| 1-a=a | 1-b=b | 2-a=c }}', 'abcd') self:preprocess_equals(pre .. '{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1-a}}}{{{1-b|{{{1-c|{{{1-d}}}}}}}}}&lt;/nowiki>|1-a}}| 1-a=a | 1-b=b | 2-a=c | 2-c=d | 3-a=e | 3-d=f }}', 'abcdef') self:preprocess_equals(pre .. '{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1-a}}}{{{1-b|{{{1-c|{{{1-d|h}}}}}}}}}&lt;/nowiki>|1-a}}| 1-a=a | 1-b=b | 2-a=c | 2-c=d | 3-a=e | 3-d=f | 4-a=g }}', 'abcdefgh')endfunction p:test_sandboxOuterSyntax ---- Test whether the module can handle being inside of HTML. self:preprocess_equals('' .. pre .. '{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1}}}&lt;/nowiki>|1}}|a|b|c}}' .. "", 'abc',) ---- Test whether the module can handle being inside of templates. self:preprocess_equals('' .. "}}", "") self:preprocess_equals_preprocess('' .. "final}}", "")endfunction p:test_sandboxInnerSyntax -- Functioning with HTML self:preprocess_equals(pre .. '{{#invoke:ArgRest/sandbox|main|<nowiki><b>{{{1}}}</b>&lt;/nowiki>|1}}|a|b|c}}', 'abc',) -- Functioning with inner templates self:preprocess_equals(pre .. '{{#invoke:ArgRest/sandbox|main|<nowiki>{{1x|{{{1}}}}}&lt;/nowiki>|1}}|a|b}}', 'ab') self:preprocess_equals(pre .. '{{#invoke:ArgRest/sandbox|main|<nowiki>{{enum|{{{1-a}}}|{{{1-b}}}}}&lt;/nowiki>|1-a}}|1-a=a|1-b=b|2-a=c|2-b=d}}', 'a and bc and d')end

return p