rust/src/test/run-pass/unwind-resource.rs
2012-11-14 19:26:37 -08:00

35 lines
567 B
Rust

// xfail-win32
extern mod std;
struct complainer {
c: comm::Chan<bool>,
}
impl complainer : Drop {
fn finalize() {
error!("About to send!");
comm::send(self.c, true);
error!("Sent!");
}
}
fn complainer(c: comm::Chan<bool>) -> complainer {
error!("Hello!");
complainer {
c: c
}
}
fn f(c: comm::Chan<bool>) {
let _c = move 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);
}