summaryrefslogtreecommitdiff
path: root/tests/typ/code/for-pattern.typ
blob: a6a7c16ae48f2e3c533a5ac0a2c5eba02fd6549e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Test for loop patterns.
// Ref: false

---
#let out = ()

// Values of array.
#for v in (1, 2, 3) {
    out += (v,)
}

// Indices and values of array.
#for i, v in ("1", "2", "3") {
    test(repr(i + 1), 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 strings.
// Error: 6-10 mismatched pattern
#for k, v in "hi" {
    dont-care
}