summaryrefslogtreecommitdiffhomepage
path: root/tests/custom/03_stdlib/09_join
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/09_join
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/09_join')
-rw-r--r--tests/custom/03_stdlib/09_join31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/custom/03_stdlib/09_join b/tests/custom/03_stdlib/09_join
new file mode 100644
index 0000000..dac49c3
--- /dev/null
+++ b/tests/custom/03_stdlib/09_join
@@ -0,0 +1,31 @@
+The `join()` function constructs a string out of the given array by
+converting each array item into a string and then joining these substrings
+putting the given separator value in between. An empty array will result in
+an empty string.
+
+The separator argument is converted into a string in case it is not already
+a string value.
+
+Returns `null` if the given array argument is not an array value.
+
+-- Testcase --
+{%
+ printf("%.J\n", [
+ join("|", []),
+ join("|", [ 1, 2, 3 ]),
+ join("|", [ null, false, "" ]),
+ join(123, [ "a", "b", "c" ]),
+ join(123, { "not": "an", "array": "value" })
+ ]);
+%}
+-- End --
+
+-- Expect stdout --
+[
+ "",
+ "1|2|3",
+ "null|false|",
+ "a123b123c",
+ null
+]
+-- End --