Module:ArgRest/testcases
| 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')
-- Empty defaults, and lack of defaults
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 }}', 'abc')
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 }}', 'abc{{{1-b}}}')
end
function p:test_outerSyntax()
---- Test whether the module can handle being inside of HTML.
self:preprocess_equals('<b>' .. pre .. '<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1}}}</nowiki>|1}}</nowiki>|a|b|c}}' .. "</b>", '<b>abc</b>', {nowiki=1})
---- Test whether the module can handle being inside of templates.
self:preprocess_equals('{{1x|' .. pre .. '<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1}}}</nowiki>|1}}</nowiki>|a|b|c}}' .. "}}", "abc")
self:preprocess_equals('{{yesno|' .. pre .. '<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1}}}</nowiki>|1}}</nowiki>|F|a|l|s|e}}' .. "|no=no}}", "no")
self:preprocess_equals_preprocess('{{enum' .. pre .. '<nowiki>{{#invoke:ArgRest|main|<nowiki>|{{{1}}}</nowiki>|1}}</nowiki>|a|b|c}}' .. "}}", "{{enum|a|b|c}}")
self:preprocess_equals_preprocess('{{enum|' .. pre .. '<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1}}}|</nowiki>|1}}</nowiki>|a|b|c}}' .. "final}}", "{{enum|a|b|c|final}}")
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')
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest|main|<nowiki>{{enum|{{{1-a}}}|{{{1-b}}}}}</nowiki>|1-a}}</nowiki>|1-a=a|1-b=b|2-a=c|2-b=d}}', 'a and bc and d')
end
-- Sandbox variants
function p:test_sandboxBasicFunctioning()
-- Functioning with unnamed parameters
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1}}}</nowiki>|1}}</nowiki>|a|b|c}}', 'abc')
self:preprocess_equals(pre .. '<nowiki>a{{#invoke:ArgRest/sandbox|main|<nowiki> + {{{1}}}</nowiki>|1}}</nowiki>|b|c|d}}', 'a + b + c + d')
self:preprocess_equals(pre .. '<nowiki>{{{1}}}{{#invoke:ArgRest/sandbox|main|<nowiki> {{{2}}}</nowiki>|2}}</nowiki>|a|b|c}}', 'a b c')
-- Functioning with named parameters
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest/sandbox|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/sandbox|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/sandbox|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/sandbox|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/sandbox|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/sandbox|main|<nowiki>{{{1-a}}}{{{1-b}}}</nowiki>|1-a}}</nowiki>| 1-a=a | 1-b=b | 2-b=d | 3-a=e }}', 'ab')
-- Empty defaults, and lack of defaults
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1-a}}}{{{1-b|}}}</nowiki>|1-a}}</nowiki>| 1-a=a | 1-b=b | 2-a=c }}', 'abc')
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1-a}}}{{{1-b}}}</nowiki>|1-a}}</nowiki>| 1-a=a | 1-b=b | 2-a=c }}', 'abc{{{1-b}}}')
-- Aliases
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1-a|{{{1-b}}}}}}</nowiki>|1-a}}</nowiki>| 1-a=a | 2-a=b | 3-b=c }}', 'abc')
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1-a|{{{1-b}}}}}}</nowiki>|1-a}}</nowiki>| 1-b=a | 2-b=b | 3-b=c }}', 'abc')
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1-a}}}{{{1-b|{{{1-c}}}}}}</nowiki>|1-a}}</nowiki>| 1-a=a | 1-b=b | 2-a=c | 2-c=d }}', 'abcd')
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1-a}}}{{{1-b|{{{1-c}}}}}}</nowiki>|1-a}}</nowiki>| 1-a=a | 1-b=b | 2-a=c }}', 'abc{{{1-c}}}')
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1-a}}}{{{1-b|{{{1-c|d}}}}}}</nowiki>|1-a}}</nowiki>| 1-a=a | 1-b=b | 2-a=c }}', 'abcd')
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1-a}}}{{{1-b|{{{1-c|{{{1-d}}}}}}}}}</nowiki>|1-a}}</nowiki>| 1-a=a | 1-b=b | 2-a=c | 2-c=d | 3-a=e | 3-d=f }}', 'abcdef')
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1-a}}}{{{1-b|{{{1-c|{{{1-d|h}}}}}}}}}</nowiki>|1-a}}</nowiki>| 1-a=a | 1-b=b | 2-a=c | 2-c=d | 3-a=e | 3-d=f | 4-a=g }}', 'abcdefgh')
end
function p:test_sandboxOuterSyntax()
---- Test whether the module can handle being inside of HTML.
self:preprocess_equals('<b>' .. pre .. '<nowiki>{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1}}}</nowiki>|1}}</nowiki>|a|b|c}}' .. "</b>", '<b>abc</b>', {nowiki=1})
---- Test whether the module can handle being inside of templates.
self:preprocess_equals('{{1x|' .. pre .. '<nowiki>{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1}}}</nowiki>|1}}</nowiki>|a|b|c}}' .. "}}", "abc")
self:preprocess_equals('{{yesno|' .. pre .. '<nowiki>{{#invoke:ArgRest/sandbox|main|<nowiki>{{{1}}}</nowiki>|1}}</nowiki>|F|a|l|s|e}}' .. "|no=no}}", "no")
self:preprocess_equals_preprocess('{{enum' .. pre .. '<nowiki>{{#invoke:ArgRest/sandbox|main|<nowiki>|{{{1}}}</nowiki>|1}}</nowiki>|a|b|c}}' .. "}}", "{{enum|a|b|c}}")
self:preprocess_equals_preprocess('{{enum|' .. pre .. '<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1}}}|</nowiki>|1}}</nowiki>|a|b|c}}' .. "final}}", "{{enum|a|b|c|final}}")
end
function p:test_sandboxInnerSyntax()
-- Functioning with HTML
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest/sandbox|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/sandbox|main|<nowiki>{{1x|{{{1}}}}}</nowiki>|1}}</nowiki>|a|b}}', 'ab')
self:preprocess_equals(pre .. '<nowiki>{{#invoke:ArgRest/sandbox|main|<nowiki>{{enum|{{{1-a}}}|{{{1-b}}}}}</nowiki>|1-a}}</nowiki>|1-a=a|1-b=b|2-a=c|2-b=d}}', 'a and bc and d')
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.