Fandom Developers Wiki
m (Add more pain)
m (Cry)
Line 18: Line 18:
 
{
 
{
 
-- Numbered args edge cases
 
-- Numbered args edge cases
'99=Luftballons|0=zero|-0=minus zero|-1=minus one|3.14=pi|1e6=dreams|99999999999999=Lua represents this as 99999999999999. It can be accessed through `frame.args` via the index operator.|100000000000000=Lua represents this as 1e+14. It \'\'cannot\'\' be accessed through `frame.args` via the index operator.|9007199254740992=2^53|9007199254740993=2^53 + 1|inf=and beyond|one',
+
'99=Luftballons|0=zero|01=no cheeky padding|-0=minus zero|-1=minus one|3.14=pi|1e6=dreams|99999999999999=Lua represents this as 99999999999999. It can be accessed through `frame.args` via the index operator.|100000000000000=Lua represents this as 1e+14. It \'\'cannot\'\' be accessed through `frame.args` via the index operator.|9007199254740992=2^53|9007199254740993=2^53 + 1|inf=and beyond|one',
'-1 => "minus one"\n0 => "zero"\n1 => "one"\n99 => "Luftballons"\n99999999999999 => "Lua represents this as 99999999999999. It can be accessed through ​`frame.args​` via the index operator."\n100000000000000 => "Lua represents this as 1e+14. It \'\'cannot\'\' be accessed through ​`frame.args​` via the index operator."\n9007199254740992 => "2^53"\n"-0" => "minus zero"\n"1e6" => "dreams"\n"3.14" => "pi"\n"9007199254740993" => "2^53 + 1"\n"inf" => "and beyond"\n'
+
'-1 => "minus one"\n0 => "zero"\n1 => "one"\n99 => "Luftballons"\n99999999999999 => "Lua represents this as 99999999999999. It can be accessed through ​`frame.args​` via the index operator."\n100000000000000 => "Lua represents this as 1e+14. It \'\'cannot\'\' be accessed through ​`frame.args​` via the index operator."\n9007199254740992 => "2^53"\n"-0" => "minus zero"\n"01" => "no cheeky padding"\n"1e6" => "dreams"\n"3.14" => "pi"\n"9007199254740993" => "2^53 + 1"\n"inf" => "and beyond"\n'
 
},
 
},
 
{
 
{

Revision as of 14:17, 22 February 2020

This module contains testcases for its parent module, Testharness.

See also


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|01=no cheeky padding|-0=minus zero|-1=minus one|3.14=pi|1e6=dreams|99999999999999=Lua represents this as 99999999999999. It can be accessed through `frame.args` via the index operator.|100000000000000=Lua represents this as 1e+14. It \'\'cannot\'\' be accessed through `frame.args` via the index operator.|9007199254740992=2^53|9007199254740993=2^53 + 1|inf=and beyond|one',
                '-1 => "minus one"\n0 => "zero"\n1 => "one"\n99 => "Luftballons"\n99999999999999 => "Lua represents this as 99999999999999. It can be accessed through ​`frame.args​` via the index operator."\n100000000000000 => "Lua represents this as 1e+14. It \'\'cannot\'\' be accessed through ​`frame.args​` via the index operator."\n9007199254740992 => "2^53"\n"-0" => "minus zero"\n"01" => "no cheeky padding"\n"1e6" => "dreams"\n"3.14" => "pi"\n"9007199254740993" => "2^53 + 1"\n"inf" => "and beyond"\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}}
            ```
            --]=]
        }
    }
}