summaryrefslogtreecommitdiffhomepage
path: root/tests/custom/03_stdlib/15_reverse
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-01-29 23:31:16 +0100
committerJo-Philipp Wich <jo@mein.io>2022-02-03 17:22:43 +0100
commit7edad5cefa0f065aa83dffd2d7830aeaf9f38662 (patch)
tree86b727f434302ffb28cb59278243517f9765e170 /tests/custom/03_stdlib/15_reverse
parentd5003fde57eab19588da7bfdbaefe93d47435eb6 (diff)
tests: add functional tests for builtin functions
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'tests/custom/03_stdlib/15_reverse')
-rw-r--r--tests/custom/03_stdlib/15_reverse31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/custom/03_stdlib/15_reverse b/tests/custom/03_stdlib/15_reverse
new file mode 100644
index 0000000..176cd4c
--- /dev/null
+++ b/tests/custom/03_stdlib/15_reverse
@@ -0,0 +1,31 @@
+The `reverse()` function returns the input argument in reverse order.
+
+Returns a reversed copy of the input string if the given input value
+argument is a string.
+
+Returns a reversed copy of the input array if the given input value
+argument is an array.
+
+Returns `null` if the input argument is neither a string nor an array.
+
+-- Testcase --
+{%
+ printf("%.J\n", [
+ reverse("abc"),
+ reverse([1, 2, 3]),
+ reverse(true)
+ ]);
+%}
+-- End --
+
+-- Expect stdout --
+[
+ "cba",
+ [
+ 3,
+ 2,
+ 1
+ ],
+ null
+]
+-- End --