!! Version 2 # Force the test runner to ensure the extension is loaded !! functionhooks af_int !! endfunctionhooks # This file tests the #af_int parser function !! test Test positive integer !! wikitext {{#af_int: 10 }} !! html
integer__^__10
!! end !! test Test negative integer !! wikitext {{#af_int: -10 }} !! htmlinteger__^__-10
!! end !! test Test zero !! wikitext {{#af_int: 0 }} !! htmlinteger__^__0
!! end !! test Test integer is idempotent !! wikitext {{#af_int: 10 }} {{#af_int: {{#af_int: 10 }} }} !! htmlinteger__^__10 integer__^__10
!! end !! test Test large number interpreted as string !! wikitext {{#af_int: 1000000000000000000000000000000000000000000000000000000000000 }} !! htmlArrayFunctions (#af_int): Could not match expected type integer with actual type string for parameter 1 ("1000000000000000000000000000000000000000000000000000000000000").
!! end !! test Test large negative number interpreted as string !! wikitext {{#af_int: -1000000000000000000000000000000000000000000000000000000000000 }} !! htmlArrayFunctions (#af_int): Could not match expected type integer with actual type string for parameter 1 ("-1000000000000000000000000000000000000000000000000000000000000").
!! end !! test Test invalid type gives error !! wikitext {{#af_int: true }} !! htmlArrayFunctions (#af_int): Could not match expected type integer with actual type string for parameter 1 ("true").
!! end !! test Test too many arguments !! wikitext {{#af_int: 1 | yes }} !! htmlArrayFunctions (#af_int): Expected at most 1 positional parameter, 2 given.
!! end !! test Test empty input !! wikitext {{#af_int: }} !! htmlArrayFunctions (#af_int): Could not match expected type integer with actual type empty for parameter 1 ("").
!! end !! test Test string !! wikitext {{#af_int: hello }} !! htmlArrayFunctions (#af_int): Could not match expected type integer with actual type string for parameter 1 ("hello").
!! end !! test Test large positive integer within valid range !! wikitext {{#af_int: 9223372036854775807 }} !! htmlinteger__^__9223372036854775807
!! end !! test Test large negative integer within valid range !! wikitext {{#af_int: -9223372036854775808 }} !! htmlinteger__^__-9223372036854775808
!! end !! test Test integer with plus sign !! wikitext {{#af_int: +10 }} !! htmlinteger__^__10
!! end