aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/roots.zc
blob: 4f058440dcd4acbdd67ee0844c387fe559a43452 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
namespace;
include rt;

// a pointer left below the live stack is not a root. scrub then clears that word.
unchecked fn main() {
	let p, slot, before, after;
	p = rt.new(2);
	p[0] = 7;
	p[1] = 8;
	slot = rt.DSLO + 8;
	*slot = p;
	before = rt.live_objects();
	p = 0;
	rt.gc();
	after = rt.live_objects();
	rt.put_n(after < before); rt.put_c(32);
	rt.scrub();
	rt.put_n(*slot); rt.put_c(10);
	return 0;
}