!! Version 2 # Force the test runner to ensure the extension is loaded !! functionhooks af_count !! endfunctionhooks # This file tests the #af_count parser function !! test Test empty list !! wikitext {{#af_count: {{AF_EMPTY}} }} !! html
integer__^__0
!! end !! test Test singleton list !! wikitext {{#af_count: {{#af_list: a}} }} !! htmlinteger__^__1
!! end !! test Test singleton nested list !! wikitext {{#af_count: {{#af_list: {{AF_EMPTY}} }} }} !! htmlinteger__^__1
!! end !! test Test multi item one-dimensional list !! wikitext {{#af_count: {{#af_list: a | b | c }} }} !! htmlinteger__^__3
!! end !! test Test multi item one-dimensional object !! wikitext {{#af_count: {{#af_object: a=a | b=b | c=c }} }} !! htmlinteger__^__3
!! end !! test Test single item multi-dimensional list !! wikitext {{#af_count: {{#af_list: {{#af_list: a }} }} }} !! htmlinteger__^__1
!! end !! test Test single item multi-dimensional list, recursive counting !! wikitext {{#af_count: {{#af_list: {{#af_list: a }} }} | recursive=yes }} !! htmlinteger__^__2
!! end !! test Test multi item multi-dimensional list, recursive counting !! wikitext {{#af_count: {{#af_list: {{#af_list: a }} | {{#af_list: b | c }} }} | recursive=yes }} !! htmlinteger__^__5
!! end !! test Test empty argument gives error !! wikitext {{#af_count: }} !! htmlArrayFunctions (#af_count): Could not match expected type array with actual type empty for parameter 1 ("").
!! end !! test Test empty argument gives error, recursive counting !! wikitext {{#af_count: | recursive=yes }} !! htmlArrayFunctions (#af_count): Could not match expected type array with actual type empty for parameter 1 ("").
!! end !! test Test invalid type gives error !! wikitext {{#af_count: foobar }} !! htmlArrayFunctions (#af_count): Could not match expected type array with actual type string for parameter 1 ("foobar").
!! end !! test Test too many arguments !! wikitext {{#af_count: {{#af_list: a | b }} | yes }} !! htmlArrayFunctions (#af_count): Expected at most 1 positional parameter, 2 given.
!! end