!! 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 }} !! html

integer__^__-10

!! end !! test Test zero !! wikitext {{#af_int: 0 }} !! html

integer__^__0

!! end !! test Test integer is idempotent !! wikitext {{#af_int: 10 }} {{#af_int: {{#af_int: 10 }} }} !! html

integer__^__10 integer__^__10

!! end !! test Test large number interpreted as string !! wikitext {{#af_int: 1000000000000000000000000000000000000000000000000000000000000 }} !! html

ArrayFunctions (#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 }} !! html

ArrayFunctions (#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 }} !! html

ArrayFunctions (#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 }} !! html

ArrayFunctions (#af_int): Expected at most 1 positional parameter, 2 given.

!! end !! test Test empty input !! wikitext {{#af_int: }} !! html

ArrayFunctions (#af_int): Could not match expected type integer with actual type empty for parameter 1 ("").

!! end !! test Test string !! wikitext {{#af_int: hello }} !! html

ArrayFunctions (#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 }} !! html

integer__^__9223372036854775807

!! end !! test Test large negative integer within valid range !! wikitext {{#af_int: -9223372036854775808 }} !! html

integer__^__-9223372036854775808

!! end !! test Test integer with plus sign !! wikitext {{#af_int: +10 }} !! html

integer__^__10

!! end