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

36 lines
559 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 std::task;
import std::task::join_id;
import std::comm;
import std::comm::_chan;
import std::comm::send;
2011-06-16 16:47:59 -05:00
fn grandchild(c: _chan<int>) { send(c, 42); }
2011-06-16 16:47:59 -05:00
fn child(c: _chan<int>) {
let _grandchild = task::_spawn(bind grandchild(c));
join_id(_grandchild);
2011-06-16 16:47:59 -05:00
}
fn main() {
let p = comm::mk_port();
2011-06-16 16:47:59 -05:00
let _child = task::_spawn(bind child(p.mk_chan()));
let x: int = p.recv();
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
join_id(_child);
}