summary refs log tree commit diff
path: root/src/test/pretty/block-disambig.rs
blob: 4157515b41c0ce7f2c2a591b691e5366a295542f (plain)
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
// A bunch of tests for syntactic forms involving blocks that were
// previously ambiguous (e.g. 'if true { } *val;' gets parsed as a
// binop)

fn test1() { let val = @0; { } *val; }

fn test2() -> int { let val = @0; { } *val }

fn test3() {
    let regs = @{mut eax: 0};
    alt check true { true { } }
    (*regs).eax = 1;
}

fn test4() -> bool { let regs = @true; if true { } *regs || false }

fn test5() -> (int, int) { { } (0, 1) }

fn test6() -> bool { { } (true || false) && true }

fn test7() -> uint {
    let regs = @0;
    alt check true { true { } }
    (*regs < 2) as uint
}

fn test8() -> int {
    let val = @0;
    alt check true {
        true { }
    }
    if *val < 1 {
        0
    } else {
        1
    }
}

fn test9() { let regs = @mut 0; alt check true { true { } } *regs += 1; }

fn test10() -> int {
    let regs = @mut [0];
    alt check true { true { } }
    (*regs)[0]
}

fn test11() -> [int] { if true { } [1, 2] }