summaryrefslogtreecommitdiffhomepage
path: root/tests/custom/03_stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/custom/03_stdlib')
-rw-r--r--tests/custom/03_stdlib/13_ord35
1 files changed, 17 insertions, 18 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 --