summaryrefslogtreecommitdiff
path: root/tests/typ/control/if.typ
blob: 4ed6b6496926bee003c652b765a0b7b42f6ac1e2 (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
// Test if-else expressions.

---
// Test condition evaluation.
#if 1 < 2 [
    Ok.
]

#if true == false [
    Bad, but we {dont-care}!
]

---
// Brace in condition.
#if {true} [
    Ok.
]

// Multi-line condition with parens.
#if (
    1 + 1
      == 1
) {
    nope
} #else {
    "Ok."
}

// Multiline.
#if false [
    Bad.
] #else {
    let pt = "."
    "Ok" + pt
}

---
// Condition must be boolean.
// If it isn't, neither branch is evaluated.
// Error: 5-14 expected boolean, found string
#if "a" + "b" { nope } #else { nope }

// Make sure that we don't complain twice.
// Error: 5-12 cannot add integer and string
#if 1 + "2" {}