rust/src/test/run-pass/comm.rs
2012-08-15 17:46:05 -07:00

26 lines
417 B
Rust

// -*- rust -*-
use std;
import comm;
import comm::Chan;
import comm::chan;
import comm::send;
import comm::recv;
import task;
fn main() {
let p = comm::port();
let ch = comm::chan(p);
let t = task::spawn(|| child(ch) );
let y = recv(p);
error!{"received"};
log(error, y);
assert (y == 10);
}
fn child(c: Chan<int>) {
error!{"sending"};
send(c, 10);
error!{"value sent"};
}