!! Version 2 # Force the test runner to ensure the extension is loaded !! functionhooks af_stringmap !! endfunctionhooks # This file tests the #af_stringmap parser function !! test Test empty value !! wikitext {{#af_stringmap:|,|x|"{{{x}}}"|,|and}} !! html !! end !! test Test empty delimiter !! wikitext {{#af_stringmap:a,b,c||x|"{{{x}}}"|,|and}} !! html
"a","b" and "c"
!! end !! test Test empty variable !! wikitext {{#af_stringmap:a,b,c|,||"{{{x}}}"|,|and}} !! htmlArrayFunctions (#af_stringmap): Could not match expected type string with actual type empty for parameter 3 ("<part><name index="2"/><value/></part>").
!! end !! test Test empty callback !! wikitext {{#af_stringmap:a,b,c|,|x||,}} !! html,,
!! end !! test Test empty new delimiter !! wikitext {{#af_stringmap:a,b,c|,|x|"{{{x}}}"||and}} !! html"a""b" and "c"
!! end !! test Test empty conjunction !! wikitext {{#af_stringmap:a,b,c|,|x|"{{{x}}}"|,|}} !! html"a","b","c"
!! end !! test Test no conjunction !! wikitext {{#af_stringmap:a,b,c|,|x|"{{{x}}}"|,}} !! html"a","b","c"
!! end !! test Test no new delimiter !! wikitext {{#af_stringmap:a,b,c|,|x|"{{{x}}}"}} !! html"a", "b", "c"
!! end !! test Test escape sequence delimiter !! wikitext {{#af_stringmap:a b c|\s|x|"{{{x}}}"}} !! html"a", "b", "c"
!! end !! test Test escape sequence new delimiter !! wikitext {{#af_stringmap:a, b, c|,|x|"{{{x}}}"|\s}} !! html"a" "b" "c"
!! end !! test Test values are trimmed !! wikitext {{#af_stringmap:a, b, c|,|x|"{{{x}}}"}} !! html"a", "b", "c"
!! end !! test Test empty delimiter and callback !! wikitext {{#af_stringmap:a, b, c||x||,}} !! html,,
!! end !! test Test empty items get removed !! wikitext {{#af_stringmap:a,,,,b,,,,c|,|x|"{{{x}}}"}} !! html"a", "b", "c"
!! end !! test Test escape sequence conjunction !! wikitext {{#af_stringmap:a,b,c|,|x|"{{{x}}}"|,\s|\s}} !! html"a", "b" "c"
!! end !! test Test too few parameters !! wikitext {{#af_stringmap:a, b, c||x}} !! htmlArrayFunctions (#af_stringmap): Expected at least 4 positional parameters, 3 given.
!! end !! test Test too many parameters !! wikitext {{#af_stringmap:a, b, c||x|"x"|,\s|and|or}} !! htmlArrayFunctions (#af_stringmap): Expected at most 6 positional parameters, 7 given.
!! end