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

38 lines
571 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 task::join;
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>) {
let _grandchild = task::spawn_joinable(copy c, grandchild);
join(_grandchild);
2011-06-16 16:47:59 -05:00
}
fn main() {
let p = comm::port();
2011-06-16 16:47:59 -05:00
let _child = task::spawn_joinable(chan(p), child);
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);
2011-06-16 16:47:59 -05:00
join(_child);
}