rust/src/test/run-pass/task-comm-0.rs
2012-07-01 19:19:32 -07:00

32 lines
578 B
Rust

use std;
import comm;
import comm::chan;
import comm::send;
import task;
fn main() { test05(); }
fn test05_start(ch : chan<int>) {
log(error, ch);
send(ch, 10);
#error("sent 10");
send(ch, 20);
#error("sent 20");
send(ch, 30);
#error("sent 30");
}
fn test05() {
let po = comm::port();
let ch = comm::chan(po);
task::spawn(|| test05_start(ch) );
let mut value = comm::recv(po);
log(error, value);
value = comm::recv(po);
log(error, value);
value = comm::recv(po);
log(error, value);
assert (value == 30);
}