rust/src/test/run-pass/alt-pattern-drop.rs
2012-06-28 14:40:31 -04:00

33 lines
548 B
Rust

// -*- rust -*-
import core::sys;
enum t { make_t(@int), clam, }
fn foo(s: @int) {
let count = sys::refcount(s);
let x: t = make_t(s); // ref up
alt x {
make_t(y) {
log(debug, y); // ref up then down
}
_ { #debug("?"); fail; }
}
log(debug, sys::refcount(s));
assert (sys::refcount(s) == count + 1u);
}
fn main() {
let s: @int = @0; // ref up
let count = sys::refcount(s);
foo(s); // ref up then down
log(debug, sys::refcount(s));
assert (sys::refcount(s) == count);
}