summaryrefslogtreecommitdiff
path: root/tests/suite/scripting/while.typ
blob: 5e452a89deb89af4ed4fe4ba0c05088195a9c260 (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
59
// Test while expressions.

--- while-loop-basic ---
// 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
}

--- while-loop-expr ---
// Value of while loops.

#test(while false {}, none)

#let i = 0
#test(type(while i < 1 [#(i += 1)]), content)

--- while-loop-condition-content-invalid ---
// Condition must be boolean.
// Error: 8-14 expected boolean, found content
#while [nope] [nope]

--- while-loop-condition-always-true ---
// Error: 8-25 condition is always true
#while 2 < "hello".len() {}

--- while-loop-limit ---
// Error: 2:2-2:24 loop seems to be infinite
#let i = 1
#while i > 0 { i += 1 }

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

// Error: 8 expected expression
#{while}

// Error: 9 expected block
#while x

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

// Error: 9 expected block
#while x something