Skip to content

Commit

Permalink
Test case for issue 2718
Browse files Browse the repository at this point in the history
This was already fixed by the time I read the issue, but more test
cases are always good.

Closes #2718
  • Loading branch information
catamorphism committed Jun 25, 2012
1 parent e9f1928 commit 91b69ae
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/test/run-pass/issue-2718.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
fn sender_terminate<T:send>(p: *packet<T>) {
}

class send_packet<T: send> {
let mut p: option<*packet<T>>;
new(p: *packet<T>) { self.p = some(p); }
drop {
if self.p != none {
let mut p = none;
p <-> self.p;
sender_terminate(option::unwrap(p))
}
}
fn unwrap() -> *packet<T> {
let mut p = none;
p <-> self.p;
option::unwrap(p)
}
}

enum state {
empty,
full,
blocked,
terminated
}

type packet<T: send> = {
mut state: state,
mut blocked_task: option<task::task>,
mut payload: option<T>
};

fn main() {
let _s: send_packet<int> = send_packet(ptr::addr_of({mut state: empty,
mut blocked_task: none,
mut payload: some(42)}));
}

0 comments on commit 91b69ae

Please sign in to comment.