2011-06-16 16:47:59 -05:00
|
|
|
|
2011-07-13 17:44:09 -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 std::task::join;
|
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
fn grandchild(c: chan[int]) { c <| 42; }
|
2011-06-16 16:47:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
fn child(c: chan[int]) {
|
|
|
|
let _grandchild = spawn grandchild(c);
|
|
|
|
join(_grandchild);
|
2011-06-16 16:47:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2011-07-27 07:19:39 -05:00
|
|
|
let p: port[int] = port();
|
2011-06-16 16:47:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
let _child = spawn child(chan(p));
|
2011-07-13 17:44:09 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
let x: int;
|
|
|
|
p |> x;
|
2011-06-16 16:47:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
log 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
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
join(_child);
|
|
|
|
}
|