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

29 lines
546 B
Rust
Raw Normal View History

// xfail-win32
use std;
import task;
import comm;
class 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!"); }
}
2011-10-20 22:34:04 -05:00
fn f(c: comm::chan<bool>) {
let _c <- complainer(c);
fail;
}
fn main() {
let p = comm::port();
let c = comm::chan(p);
let builder = task::builder();
2012-02-18 18:34:42 -06:00
task::unsupervise(builder);
2012-06-30 18:19:07 -05:00
task::run(builder, || f(c) );
#error("hiiiiiiiii");
assert comm::recv(p);
}