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

26 lines
457 B
Rust
Raw Normal View History

// xfail-win32
use std;
2012-08-15 20:46:55 -05:00
struct complainer {
2012-08-15 16:10:46 -05:00
let c: comm::Chan<bool>;
new(c: comm::Chan<bool>) {
2012-08-22 19:24:52 -05:00
error!("Hello!");
self.c = c; }
2012-08-22 19:24:52 -05:00
drop { error!("About to send!");
comm::send(self.c, true);
2012-08-22 19:24:52 -05:00
error!("Sent!"); }
}
2012-08-15 16:10:46 -05:00
fn f(c: comm::Chan<bool>) {
let _c <- complainer(c);
fail;
}
fn main() {
2012-08-27 16:22:25 -05:00
let p = comm::Port();
let c = comm::Chan(p);
task::spawn_unlinked(|| f(c) );
2012-08-22 19:24:52 -05:00
error!("hiiiiiiiii");
assert comm::recv(p);
}