diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-01-29 23:31:16 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-02-03 17:22:43 +0100 |
commit | 7edad5cefa0f065aa83dffd2d7830aeaf9f38662 (patch) | |
tree | 86b727f434302ffb28cb59278243517f9765e170 /tests/custom/03_stdlib/08_int | |
parent | d5003fde57eab19588da7bfdbaefe93d47435eb6 (diff) |
tests: add functional tests for builtin functions
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'tests/custom/03_stdlib/08_int')
-rw-r--r-- | tests/custom/03_stdlib/08_int | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/custom/03_stdlib/08_int b/tests/custom/03_stdlib/08_int new file mode 100644 index 0000000..a6b5923 --- /dev/null +++ b/tests/custom/03_stdlib/08_int @@ -0,0 +1,42 @@ +The `int()` function converts the given value into a signed integer +value and returns the resulting number. + +Returns `NaN` if the given argument is not convertible into a number. + +Returns `NaN` if the conversion result is out of range. + +-- Testcase -- +{% + printf("%.J\n", [ + int(), + int(false), + int(123), + int(456.789), + int(""), + int("invalid"), + int("deaf"), + int("0x1000"), + int("0xffffffffffffffff"), + int("0177"), + int("+145"), + int("-96") + ]); +%} +-- End -- + +-- Expect stdout -- +[ + 0, + 0, + 123, + 456, + 0, + "NaN", + "NaN", + 4096, + "NaN", + 127, + "NaN", + -96 +] +-- End -- |