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

28 lines
482 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);
task::spawn_unlinked(|| f(c) );
#error("hiiiiiiiii");
assert comm::recv(p);
}