summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/custom/03_stdlib/13_ord35
-rw-r--r--tests/custom/04_bugs/19_truncated_format_string2
-rw-r--r--tests/custom/04_bugs/31_vallist_8bit_shortstrings2
3 files changed, 19 insertions, 20 deletions
diff --git a/tests/custom/03_stdlib/13_ord b/tests/custom/03_stdlib/13_ord
index 3a69228..7edeff0 100644
--- a/tests/custom/03_stdlib/13_ord
+++ b/tests/custom/03_stdlib/13_ord
@@ -1,19 +1,14 @@
-The `ord()` function extracts the byte values of characters within the
-given input string at different offsets, depending on the arguments.
+The `ord()` function extracts the byte value of the character within the
+given input string at the given offset.
-Without further arguments, the function will return the byte value of
-the first character within the given string.
-
-If one or more offset arguments are given, the function returns an array
-containing the byte values of each character at the corresponding offset.
+If the offset argument is omitted, the byte value of the first character
+is returned.
Returns `null` if the given input string argument is not a string.
-Returns `null` if the given input string is empty and no offset arguments
-are provided.
+Returns `null` if the given input string is empty.
-If invalid offsets are given, the corresponding values within the result
-array will be set to `null`.
+Returns `null` if the given offset value is invalid.
Invalid offsets are non-integer values or integers equal to or larger than
the length of the input string. Negative offsets are converted to positive
@@ -26,11 +21,13 @@ too large, the offset is considered invalid.
print(join("\n", [
ord(123),
ord(""),
+ ord("abcd", "inval"),
ord("abcd"),
ord("abcd", 0),
- ord("abcd", 1, 3, 2),
- ord("abcd", -1, -2),
- ord("abcd", -10, 10)
+ ord("abcd", 1),
+ ord("abcd", -1),
+ ord("abcd", 10),
+ ord("abcd", -10)
]), "\n");
%}
-- End --
@@ -38,9 +35,11 @@ too large, the offset is considered invalid.
-- Expect stdout --
null
null
+null
+97
97
-[ 97 ]
-[ 98, 100, 99 ]
-[ 100, 99 ]
-[ null, null ]
+98
+100
+null
+null
-- End --
diff --git a/tests/custom/04_bugs/19_truncated_format_string b/tests/custom/04_bugs/19_truncated_format_string
index 8ddd0a3..ead0fdb 100644
--- a/tests/custom/04_bugs/19_truncated_format_string
+++ b/tests/custom/04_bugs/19_truncated_format_string
@@ -9,6 +9,6 @@ to the resulting string.
-- Testcase --
{%
let s = sprintf("%");
- print(ord(s, 0, 1), "\n");
+ print([ ord(s, 0), ord(s, 1) ], "\n");
%}
-- End --
diff --git a/tests/custom/04_bugs/31_vallist_8bit_shortstrings b/tests/custom/04_bugs/31_vallist_8bit_shortstrings
index 98ccf0b..9d02f42 100644
--- a/tests/custom/04_bugs/31_vallist_8bit_shortstrings
+++ b/tests/custom/04_bugs/31_vallist_8bit_shortstrings
@@ -3,7 +3,7 @@ to/from pointer addresses, 8 bit characters where incorrectly clamped
to `-1` (`255`).
-- Testcase --
-{{ ord("ö", 1)[0] != -1 }}
+{{ ord("ö", 1) != -1 }}
-- End --
-- Expect stdout --