mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-26 23:42:15 +00:00
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { link_count, unlink_count, collect_count } from "./gc/_dummy";
|
|
export { runtime, gc };
|
|
|
|
class Ref {}
|
|
|
|
@start export function main(): void {
|
|
var ref = new Ref();
|
|
|
|
assert(gc.implemented);
|
|
|
|
var previous_link_count = link_count;
|
|
var previous_unlink_count = unlink_count;
|
|
var previous_collect_count = collect_count;
|
|
|
|
gc.retain(changetype<usize>(ref));
|
|
|
|
assert(link_count == previous_link_count + 1);
|
|
assert(unlink_count == previous_unlink_count);
|
|
assert(collect_count == previous_collect_count);
|
|
previous_link_count = link_count;
|
|
previous_unlink_count = unlink_count;
|
|
previous_collect_count = collect_count;
|
|
|
|
gc.release(changetype<usize>(ref));
|
|
|
|
assert(link_count == previous_link_count);
|
|
assert(unlink_count == previous_unlink_count + 1);
|
|
assert(collect_count == previous_collect_count);
|
|
previous_link_count = link_count;
|
|
previous_unlink_count = unlink_count;
|
|
previous_collect_count = collect_count;
|
|
|
|
gc.collect();
|
|
|
|
assert(link_count == previous_link_count);
|
|
assert(unlink_count == previous_unlink_count);
|
|
assert(collect_count == previous_collect_count + 1);
|
|
}
|