rust/src/test/run-pass/unwind-resource.rs

35 lines
572 B
Rust
Raw Normal View History

// xfail-win32
extern mod std;
2012-08-15 20:46:55 -05:00
struct complainer {
2012-09-06 21:40:15 -05:00
c: comm::Chan<bool>,
}
impl complainer : Drop {
fn finalize(&self) {
error!("About to send!");
comm::send(self.c, true);
error!("Sent!");
}
}
2012-09-05 17:58:43 -05:00
fn complainer(c: comm::Chan<bool>) -> complainer {
error!("Hello!");
complainer {
c: c
}
}
2012-08-15 16:10:46 -05:00
fn f(c: comm::Chan<bool>) {
let _c = move complainer(c);
fail;
}
fn main() {
2012-08-27 16:22:25 -05:00
let p = comm::Port();
2012-10-03 16:38:01 -05:00
let c = comm::Chan(&p);
task::spawn_unlinked(|| f(c) );
2012-08-22 19:24:52 -05:00
error!("hiiiiiiiii");
assert comm::recv(p);
}