Skip to content

Commit

Permalink
Tests on-exit garbage collection in conc.
Browse files Browse the repository at this point in the history
  • Loading branch information
ticki committed Jul 25, 2017
1 parent dfc113e commit ab3c74d
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions conc/src/global.rs
Expand Up @@ -248,11 +248,21 @@ mod tests {

#[test]
fn clean_up_state() {
fn dtor(_: *const u8) {}
fn dtor(x: *const u8) {
unsafe {
*(x as *mut u8) = 1;
}
}

let s = State::new();
let b = Box::new(0);
s.export_garbage(vec![Garbage::new(&*b, dtor)]);
for _ in 0..1000 {
let b = Box::new(0);
{
let s = State::new();
s.export_garbage(vec![Garbage::new(&*b, dtor)]);
}

assert_eq!(*b, 1);
}
}

#[test]
Expand Down

0 comments on commit ab3c74d

Please sign in to comment.