summaryrefslogtreecommitdiff
path: root/tests/typ/code/while.typ
blob: 2f0984d216faad9ae8be0ef4b89dbef6e80a3769 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Test while expressions.

---
// Should output `2 4 6 8 10`.
#let i = 0
#while i < 10 [
    { i += 2 }
    #i
]

// Should output `Hi`.
#let iter = true
#while iter {
    iter = false
    "Hi."
}

#while false {
    dont-care
}

---
// Value of while loops.
// Ref: false

#test(while false {}, none)

#let i = 0
#test(type(while i < 1 [{ i += 1 }]), "template")

---
// Condition must be boolean.
// Error: 8-14 expected boolean, found template
#while [nope] [nope]

---
// Make sure that we terminate and don't complain multiple times.
#while true {
    // Error: 5-9 unknown variable
    nope
}

---
// Error: 7 expected expression
#while

// Error: 7 expected expression
{while}

// Error: 9 expected body
#while x

// Error: 7 expected expression
#while
x {}

// Error: 9 expected body
#while x something