Jump to content

Module:ArgRest/testcases

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Lemondoge (talk | contribs) at 23:32, 30 March 2023 (Created a testcases page; let's see if I didn't goof the making of this). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
-- Unit tests for [[Module:{{ROOTPAGENAME}}]]. Click talk page to run tests.
local p = require('Module:UnitTests')

function p:test_basicFunctioning()
	-- Functioning with unnamed parameters
	self:preprocess_equals('{{#invoke:ArgRest/testCaser | main |<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1}}}&lt;/nowiki>|1}}</nowiki>| a | b | c }}', 'abc')
	self:preprocess_equals('a{{#invoke:ArgRest/testCaser | main |<nowiki>{{#invoke:ArgRest|main|<nowiki> + {{{1}}}&lt;/nowiki>|1}}</nowiki>| b | c | d }}', 'a + b + c + d')
	self:preprocess_equals('{{{1}}}{{#invoke:ArgRest/testCaser | main |<nowiki>{{#invoke:ArgRest|main|<nowiki> {{{2}}}&lt;/nowiki>|2}}</nowiki>| a | b | c }}', 'a b c')
	-- Functioning with named parameters
	self:preprocess_equals('{{#invoke:ArgRest/testCaser | main |<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1-a}}}{{{1-b}}}&lt;/nowiki>|1-a}}</nowiki>| 1-a=a | 1-b=b | 2-a=c | 2-b=d }}', 'abcd')
	self:preprocess_equals('{{{1-a}}} - {{{1-b}}}{{#invoke:ArgRest/testCaser | main |<nowiki>{{#invoke:ArgRest|main|<nowiki> + {{{2-a}}} - {{2-b}}}&lt;/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('{{#invoke:ArgRest/testCaser | main |<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1-a}}}{{{1-b|d}}}&lt;/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:equals('{{#invoke:ArgRest/testCaser | main |<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1-a}}}{{{1-b}}}&lt;/nowiki>|1-a}}</nowiki>| 1-a=a | 1-b=b | 2-b=d }}', 'ab')
	self:equals('{{#invoke:ArgRest/testCaser | main |<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1-a|c}}}{{{1-b}}}&lt;/nowiki>|1-a}}</nowiki>| 1-a=a | 1-b=b | 2-b=d }}', 'ab')
	self:equals('{{#invoke:ArgRest/testCaser | main |<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1-a}}}{{{1-b}}}&lt;/nowiki>|1-a}}</nowiki>| 1-a=a | 1-b=b | 2-b=d | 3-a=e }}', 'ab')
end

return p