about summary refs log tree commit diff
path: root/src/test/run-pass/basic.rs
blob: e162b3aba85c217c1903de5a6f30efc60f9945cd (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
// -*- rust -*-

use std;
import comm;
import comm::send;
import comm::chan;
import comm::recv;
import task;

fn a(c: chan<int>) {
    if true {
        log "task a";
        log "task a";
        log "task a";
        log "task a";
        log "task a";
    }
    send(c, 10);
}

fn k(x: int) -> int { ret 15; }

fn g(x: int, y: str) -> int { log x; log y; let z: int = k(1); ret z; }

fn main() {
    let n: int = 2 + 3 * 7;
    let s: str = "hello there";
    let p = comm::port();
    task::spawn(chan(p), a);
    task::spawn(chan(p), b);
    let x: int = 10;
    x = g(n, s);
    log x;
    n = recv(p);
    n = recv(p);
    // FIXME: use signal-channel for this.
    log "children finished, root finishing";
}

fn b(c: chan<int>) {
    if true {
        log "task b";
        log "task b";
        log "task b";
        log "task b";
        log "task b";
        log "task b";
    }
    send(c, 10);
}