summaryrefslogtreecommitdiffhomepage
path: root/tests/custom/03_stdlib/07_hex
diff options
context:
space:
mode:
Diffstat (limited to 'tests/custom/03_stdlib/07_hex')
-rw-r--r--tests/custom/03_stdlib/07_hex33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/custom/03_stdlib/07_hex b/tests/custom/03_stdlib/07_hex
new file mode 100644
index 0000000..419970c
--- /dev/null
+++ b/tests/custom/03_stdlib/07_hex
@@ -0,0 +1,33 @@
+The `hex()` function converts the given hexadecimal string into a signed
+integer value and returns the resulting number.
+
+Returns `NaN` if the given argument is not a string, an empty string or
+a string containing non-hexadecimal digits.
+
+-- Testcase --
+{%
+ printf("%.J\n", [
+ hex(),
+ hex(false),
+ hex(123),
+ hex(""),
+ hex("invalid"),
+ hex("deaf"),
+ hex("0x1000"),
+ hex("ffffffffffffffff")
+ ]);
+%}
+-- End --
+
+-- Expect stdout --
+[
+ "NaN",
+ "NaN",
+ "NaN",
+ "NaN",
+ "NaN",
+ 57007,
+ 4096,
+ 9223372036854775807
+]
+-- End --