rust/src/test/run-pass/issue-507.rs

35 lines
483 B
Rust
Raw Normal View History

2011-06-16 16:47:59 -05:00
/*
2011-06-16 16:47:59 -05:00
This is a test case for Issue 507.
https://github.com/graydon/rust/issues/507
*/
use std;
import task;
import comm;
import comm::chan;
import comm::send;
import comm::port;
import comm::recv;
2011-06-16 16:47:59 -05:00
2011-10-20 22:34:04 -05:00
fn grandchild(c: chan<int>) { send(c, 42); }
2011-06-16 16:47:59 -05:00
2011-10-20 22:34:04 -05:00
fn child(c: chan<int>) {
2012-02-18 18:34:42 -06:00
task::spawn {|| grandchild(c); }
2011-06-16 16:47:59 -05:00
}
fn main() {
let p = comm::port();
2012-01-04 23:14:53 -06:00
let ch = chan(p);
2011-06-16 16:47:59 -05:00
2012-02-18 18:34:42 -06:00
task::spawn {|| child(ch); }
let x: int = recv(p);
2011-06-16 16:47:59 -05:00
log(debug, x);
2011-06-16 16:47:59 -05:00
2011-07-27 07:19:39 -05:00
assert (x == 42);
}