rust/src/test/run-pass/unwind-resource.rs
2012-08-17 10:13:45 -07:00

28 lines
483 B
Rust

// xfail-win32
use std;
import task;
import comm;
struct complainer {
let c: comm::Chan<bool>;
new(c: comm::Chan<bool>) {
error!{"Hello!"};
self.c = c; }
drop { error!{"About to send!"};
comm::send(self.c, true);
error!{"Sent!"}; }
}
fn f(c: comm::Chan<bool>) {
let _c <- complainer(c);
fail;
}
fn main() {
let p = comm::port();
let c = comm::chan(p);
task::spawn_unlinked(|| f(c) );
error!{"hiiiiiiiii"};
assert comm::recv(p);
}