rust/src/test/run-pass/task-comm-0.rs

30 lines
523 B
Rust
Raw Normal View History

use std;
2012-07-25 14:05:06 -07:00
import pipes;
import pipes::chan;
import pipes::port;
import task;
2011-07-27 14:19:39 +02:00
fn main() { test05(); }
2011-10-20 20:34:04 -07:00
fn test05_start(ch : chan<int>) {
2012-07-25 14:05:06 -07:00
ch.send(10);
2012-08-22 17:24:52 -07:00
error!("sent 10");
2012-07-25 14:05:06 -07:00
ch.send(20);
2012-08-22 17:24:52 -07:00
error!("sent 20");
2012-07-25 14:05:06 -07:00
ch.send(30);
2012-08-22 17:24:52 -07:00
error!("sent 30");
}
2011-04-19 13:35:49 -07:00
fn test05() {
2012-07-25 14:05:06 -07:00
let (ch, po) = pipes::stream();
2012-06-30 16:19:07 -07:00
task::spawn(|| test05_start(ch) );
2012-07-25 14:05:06 -07:00
let mut value = po.recv();
log(error, value);
2012-07-25 14:05:06 -07:00
value = po.recv();
log(error, value);
2012-07-25 14:05:06 -07:00
value = po.recv();
log(error, value);
assert (value == 30);
}