summaryrefslogtreecommitdiffhomepage
path: root/tests/00_syntax/14_array_literals
diff options
context:
space:
mode:
Diffstat (limited to 'tests/00_syntax/14_array_literals')
-rw-r--r--tests/00_syntax/14_array_literals25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/00_syntax/14_array_literals b/tests/00_syntax/14_array_literals
new file mode 100644
index 0000000..ea5f9c0
--- /dev/null
+++ b/tests/00_syntax/14_array_literals
@@ -0,0 +1,25 @@
+The utpl script language supports declaring arrays using JSON notation.
+
+-- Expect stdout --
+[ ]
+[ "first", "second", 123, [ "a", "nested", "array" ], { "a": "nested object" } ]
+-- End --
+
+-- Testcase --
+{%
+ // An empty array can be declared using a pair of square brackets
+ empty_array = [ ];
+
+ // JSON notation is used to declare an array with contents
+ json_array = [
+ "first",
+ "second",
+ 123,
+ [ "a", "nested", "array" ],
+ { a: "nested object" }
+ ];
+
+ // Printing (or stringifying) arrays will return their JSON representation
+ print(empty_array, "\n");
+ print(json_array, "\n");
+-- End --