summaryrefslogtreecommitdiff
path: root/tests/typ/control/for-pattern.typ
diff options
context:
space:
mode:
Diffstat (limited to 'tests/typ/control/for-pattern.typ')
-rw-r--r--tests/typ/control/for-pattern.typ30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/typ/control/for-pattern.typ b/tests/typ/control/for-pattern.typ
new file mode 100644
index 00000000..38253b33
--- /dev/null
+++ b/tests/typ/control/for-pattern.typ
@@ -0,0 +1,30 @@
+// Test for loop patterns.
+// Ref: false
+
+---
+#let out = ()
+
+// Values of array.
+#for v in (1, 2, 3) {
+ out += (v,)
+}
+
+// Values of dictionary.
+#for v in (a: 4, b: 5) {
+ out += (v,)
+}
+
+// Keys and values of dictionary.
+#for k, v in (a: 6, b: 7) {
+ out += (k,)
+ out += (v,)
+}
+
+#test(out, (1, 2, 3, 4, 5, "a", 6, "b", 7))
+
+---
+// Keys and values of array.
+// Error: 6-10 mismatched pattern
+#for k, v in (-1, -2, -3) {
+ dont-care
+}