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

38 lines
603 B
Rust

/*
This is a test case for Issue 507.
https://github.com/graydon/rust/issues/507
*/
use std;
import std::task;
import std::task::join;
import std::comm;
import std::comm::chan;
import std::comm::send;
import std::comm::port;
import std::comm::recv;
fn grandchild(c: chan<int>) { send(c, 42); }
fn child(c: chan<int>) {
let _grandchild = task::spawn_joinable(bind grandchild(c));
join(_grandchild);
}
fn main() {
let p = comm::port();
let _child = task::spawn_joinable(bind child(chan(p)));
let x: int = recv(p);
log x;
assert (x == 42);
join(_child);
}