2010-08-27 15:27:28 -05:00
|
|
|
|
2011-06-15 13:19:50 -05:00
|
|
|
|
|
|
|
// -*- rust -*-
|
2010-08-27 15:27:28 -05:00
|
|
|
use std;
|
2011-05-17 13:41:41 -05:00
|
|
|
import std::str;
|
2010-08-27 15:27:28 -05:00
|
|
|
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2011-05-12 10:24:54 -05:00
|
|
|
// FIXME: import std::dbg.const_refcount. Currently
|
2010-11-09 16:15:07 -06:00
|
|
|
// cross-crate const references don't work.
|
2011-07-27 07:19:39 -05:00
|
|
|
const const_refcount: uint = 0x7bad_face_u;
|
2010-11-09 16:15:07 -06:00
|
|
|
|
2011-06-15 13:19:50 -05:00
|
|
|
tag t { make_t(str); clam; }
|
2010-08-27 15:27:28 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
fn foo(s: str) {
|
|
|
|
let x: t = make_t(s); // ref up
|
2010-08-27 15:27:28 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
alt x {
|
|
|
|
make_t(y) {
|
|
|
|
log y; // ref up then down
|
2010-08-27 15:27:28 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
}
|
|
|
|
_ { log "?"; fail; }
|
2011-06-15 13:19:50 -05:00
|
|
|
}
|
|
|
|
log str::refcount(s);
|
|
|
|
assert (str::refcount(s) == const_refcount);
|
2010-08-27 15:48:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2011-07-27 07:19:39 -05:00
|
|
|
let s: str = "hi"; // ref up
|
2011-06-15 13:19:50 -05:00
|
|
|
|
|
|
|
foo(s); // ref up then down
|
|
|
|
|
|
|
|
log str::refcount(s);
|
|
|
|
assert (str::refcount(s) == const_refcount);
|
2011-08-19 17:16:48 -05:00
|
|
|
}
|