2010-08-27 13:27:28 -07:00
|
|
|
|
2011-06-15 11:19:50 -07:00
|
|
|
|
|
|
|
// -*- rust -*-
|
2012-06-28 14:40:31 -04:00
|
|
|
import core::sys;
|
2011-06-15 11:19:50 -07:00
|
|
|
|
2012-01-19 18:31:08 -08:00
|
|
|
enum t { make_t(@int), clam, }
|
2010-08-27 13:27:28 -07:00
|
|
|
|
2011-08-31 15:23:34 -07:00
|
|
|
fn foo(s: @int) {
|
2012-06-28 14:40:31 -04:00
|
|
|
let count = sys::refcount(s);
|
2011-07-27 14:19:39 +02:00
|
|
|
let x: t = make_t(s); // ref up
|
2010-08-27 13:27:28 -07:00
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
alt x {
|
|
|
|
make_t(y) {
|
2011-12-22 17:53:53 -08:00
|
|
|
log(debug, y); // ref up then down
|
2010-08-27 13:27:28 -07:00
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
}
|
2011-12-22 14:42:52 -08:00
|
|
|
_ { #debug("?"); fail; }
|
2011-06-15 11:19:50 -07:00
|
|
|
}
|
2012-06-28 14:40:31 -04:00
|
|
|
log(debug, sys::refcount(s));
|
|
|
|
assert (sys::refcount(s) == count + 1u);
|
2010-08-27 13:48:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2011-08-31 15:23:34 -07:00
|
|
|
let s: @int = @0; // ref up
|
2011-06-15 11:19:50 -07:00
|
|
|
|
2012-06-28 14:40:31 -04:00
|
|
|
let count = sys::refcount(s);
|
2012-06-04 10:44:19 -07:00
|
|
|
|
2011-06-15 11:19:50 -07:00
|
|
|
foo(s); // ref up then down
|
|
|
|
|
2012-06-28 14:40:31 -04:00
|
|
|
log(debug, sys::refcount(s));
|
|
|
|
assert (sys::refcount(s) == count);
|
2011-08-19 15:16:48 -07:00
|
|
|
}
|