From 7edad5cefa0f065aa83dffd2d7830aeaf9f38662 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sat, 29 Jan 2022 23:31:16 +0100 Subject: tests: add functional tests for builtin functions Signed-off-by: Jo-Philipp Wich --- tests/custom/03_stdlib/15_reverse | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/custom/03_stdlib/15_reverse (limited to 'tests/custom/03_stdlib/15_reverse') 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 -- -- cgit v1.2.3