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;
|
|
|
|
|
2011-12-13 18:25:51 -06:00
|
|
|
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() {
|
2011-08-25 13:20:43 -05:00
|
|
|
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); }
|
2011-07-13 17:44:09 -05:00
|
|
|
|
2011-08-25 13:20:43 -05:00
|
|
|
let x: int = recv(p);
|
2011-06-16 16:47:59 -05:00
|
|
|
|
2011-12-22 19:53:53 -06:00
|
|
|
log(debug, x);
|
2011-06-16 16:47:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
assert (x == 42);
|
2011-08-10 11:27:22 -05:00
|
|
|
}
|