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

28 lines
483 B
Rust
Raw Normal View History

// xfail-win32
use std;
import task;
import comm;
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>) {
error!{"Hello!"};
self.c = c; }
drop { error!{"About to send!"};
comm::send(self.c, true);
error!{"Sent!"}; }
}
2012-08-15 16:10:46 -05:00
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);
}