return {
dump_args = {
options = {
mode = 'invocation',
nowiki = true
},
tests = {
{
-- Anonymous args
'one|two|buckle my shoe',
'1 => "one"\n2 => "two"\n3 => "buckle my shoe"\n'
},
{
-- Out-of-order anonymous and numbered args with overriding
'first|overridden second|3=overridden third|third|2=second|fourth',
'1 => "first"\n2 => "second"\n3 => "third"\n4 => "fourth"\n'
},
{
-- Numbered args edge cases
'99=Luftballons|0=zero|-1=minus one|3.14=pi|one',
'-1 => "minus one"\n0 => "zero"\n1 => "one"\n99 => "Luftballons"\n"3.14" => "pi"\n'
},
{
-- Whitespace preservation on anonymous args
' My hovercraft is full of eels. ',
'1 => " My hovercraft is full of eels. "\n'
},
{
-- Whitespace stripping on numbered args
'1= My hovercraft is full of eels. ',
'1 => "My hovercraft is full of eels."\n'
},
{
-- Named args (including whitespace stripping)
"when=you walk away| you = don't hear me say ",
'"when" => "you walk away"\n"you" => "don\'t hear me say"\n'
},
{
-- Named arg (where the arg name has a space)
'"pleeeeeeeeeeeeeease, oh baby, don\'t go"|simple and clean = the way that you\'re making me feel tonight',
'1 => "\\"pleeeeeeeeeeeeeease, oh baby, don\'t go\\""\n"simple and clean" => "the way that you\'re making me feel tonight"\n'
},
{
-- Empty named arg + no wikitext-to-HTML processing
"== wikitext ==\n* to [[wikipedia:HTML|HTML]] conversion\n* should ''not'' happen at this stage",
'"" => "= wikitext ==\\\n* to [[wikipedia:HTML|HTML]] conversion\\\n* should \'\'not\'\' happen at this stage"'
},
{
-- Preprocessing of arg keys and values
'{{!}}{{#if:x|8|WTF}}{{=}}{{))}}|{{!}}{{#if:x|8|WTF}}{{=}}{{))}}={{!}}{{#if:x|8|WTF}}{{=}}{{))}}',
'1 => "|8=}}"\n"|8=}}" => "|8=}}"\n'
}
--[=[
TODO: Deal with the likes of:
```
{{#invoke:testharness/testmodule|dump_args|a=b
=d}}
```
... and...
```
{{#invoke:testharness/testmodule|dump_args|{{deliberately{{im}properly}balanced}}=oof}}
```
--]=]
}
}
}
Advertisement
Advertisement