about summary refs log tree commit diff
path: root/src/test/run-pass/weird-exprs.rs
blob: 797ed1b0f39bf92301ec4fdd43106775546c6c41 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Just a grab bag of stuff that you wouldn't want to actually write.

fn strange() -> bool { let _x = ret true; }

fn funny() {
    fn f(_x: ()) { }
    f(ret);
}

fn what() {
    fn the(x: @mutable bool) { ret while !*x { *x = true; }; }
    let i = @mutable false;
    let dont = bind the(i);
    dont();
    assert (*i);
}

fn zombiejesus() {
    do  {
        while (ret) {
            if (ret) {
                alt (ret) { _ { ret ? ret : ret } };
            } else if (ret) {
                ret;
            }
        }
    } while ret
}

fn notsure() {
    let _x;
    let _y = (_x = 0) == (_x = 0);
    let _z = (_x <- 0) < (_x = 0);
    let _a = (_x += 0) == (_x = 0);
    let _b = (_y <-> _z) == (_y <-> _z);
}

fn hammertime() -> int {
    let _x = log true == (ret 0);
}

fn canttouchthis() -> uint {
    pure fn p() -> bool { true }
    let _a = (assert (true)) == (check (p()));
    let _c = (check (p())) == ();
    let _b = (log 0) == (ret 0u);
}

fn angrydome() {
    while true { if break { } }
    let i = 0;
    do  { i += 1; if i == 1 { alt cont { _ { } } } } while false
}

fn evil_lincoln() { let evil <- log "lincoln"; }

fn main() {
    strange();
    funny();
    what();
    zombiejesus();
    notsure();
    hammertime();
    canttouchthis();
    angrydome();
    evil_lincoln();
}