!! Version 2 # Force the test runner to ensure the extension is loaded !! functionhooks af_float !! endfunctionhooks # This file tests the #af_float parser function !! test Test positive integer float !! wikitext {{#af_float: 10 }} !! html
float__^__10
!! end !! test Test positive float !! wikitext {{#af_float: 10.12 }} !! htmlfloat__^__10.12
!! end !! test Test negative integer float !! wikitext {{#af_float: -10 }} !! htmlfloat__^__-10
!! end !! test Test negative float !! wikitext {{#af_float: -10.12 }} !! htmlfloat__^__-10.12
!! end !! test Test large float !! wikitext {{#af_float: 100000000000000000000000000000000.0 }} !! htmlfloat__^__1.0E+32
!! end !! test Test large negative float !! wikitext {{#af_float: -100000000000000000000000000000000.0 }} !! htmlfloat__^__-1.0E+32
!! end !! test Test large float as E notation !! wikitext {{#af_float: 1.0E+32 }} !! htmlfloat__^__1.0E+32
!! end !! test Test large negative float as E notation !! wikitext {{#af_float: -1.0E+32 }} !! htmlfloat__^__-1.0E+32
!! end !! test Test small float !! wikitext {{#af_float: 0.00000000000000000000000000000001 }} !! htmlfloat__^__1.0E-32
!! end !! test Test small negative float !! wikitext {{#af_float: -0.00000000000000000000000000000001 }} !! htmlfloat__^__-1.0E-32
!! end !! test Test small float as E notation !! wikitext {{#af_float: 1.0E-32 }} !! htmlfloat__^__1.0E-32
!! end !! test Test small negative float as E notation !! wikitext {{#af_float: -1.0E-32 }} !! htmlfloat__^__-1.0E-32
!! end !! test Test float is idempotent !! wikitext {{#af_float: 10.0 }} {{#af_float: {{#af_float: 10.0 }} }} !! htmlfloat__^__10 float__^__10
!! end !! test Test invalid type gives error !! wikitext {{#af_float: true }} !! htmlArrayFunctions (#af_float): Could not match expected type float with actual type string for parameter 1 ("true").
!! end !! test Test too many arguments !! wikitext {{#af_float: 1.0 | yes }} !! htmlArrayFunctions (#af_float): Expected at most 1 positional parameter, 2 given.
!! end !! test Test zero as float !! wikitext {{#af_float: 0 }} !! htmlfloat__^__0
!! end !! test Test whitespace-only input gives error !! wikitext {{#af_float: }} !! htmlArrayFunctions (#af_float): Could not match expected type float with actual type empty for parameter 1 ("").
!! end !! test Test invalid string gives error !! wikitext {{#af_float: abc }} !! htmlArrayFunctions (#af_float): Could not match expected type float with actual type string for parameter 1 ("abc").
!! end !! test Test boolean true gives error !! wikitext {{#af_float: true }} !! htmlArrayFunctions (#af_float): Could not match expected type float with actual type string for parameter 1 ("true").
!! end !! test Test boolean false gives error !! wikitext {{#af_float: false }} !! htmlArrayFunctions (#af_float): Could not match expected type float with actual type string for parameter 1 ("false").
!! end !! test Test float representation of a large integer !! wikitext {{#af_float: 1000000000 }} !! htmlfloat__^__1000000000
!! end !! test Test float representation of a small integer !! wikitext {{#af_float: 1 }} !! htmlfloat__^__1
!! end !! test Test float representation of a negative integer !! wikitext {{#af_float: -42 }} !! htmlfloat__^__-42
!! end !! test Test float representation of a positive number with trailing zeros !! wikitext {{#af_float: 100.0000 }} !! htmlfloat__^__100
!! end !! test Test float representation of a negative number with trailing zeros !! wikitext {{#af_float: -100.0000 }} !! htmlfloat__^__-100
!! end !! test Test float with many decimal places !! wikitext {{#af_float: 3.14159265358979323846 }} !! htmlfloat__^__3.1415926535898
!! end !! test Test large positive float in scientific notation !! wikitext {{#af_float: 1.23E+10 }} !! htmlfloat__^__12300000000
!! end !! test Test large negative float in scientific notation !! wikitext {{#af_float: -1.23E+10 }} !! htmlfloat__^__-12300000000
!! end !! test Test very small positive float in scientific notation !! wikitext {{#af_float: 1.23E-10 }} !! htmlfloat__^__1.23E-10
!! end !! test Test very small negative float in scientific notation !! wikitext {{#af_float: -1.23E-10 }} !! htmlfloat__^__-1.23E-10
!! end !! test Test input with leading zeros !! wikitext {{#af_float: 0000123.45 }} !! htmlfloat__^__123.45
!! end !! test Test input with invalid extra arguments !! wikitext {{#af_float: 3.14 | extra }} !! htmlArrayFunctions (#af_float): Expected at most 1 positional parameter, 2 given.
!! end