use prometeu_bytecode::Value; use prometeu_vm::Heap; #[test] fn gc_collects_unreachable_closure_but_keeps_marked() { let mut heap = Heap::new(); // Allocate two closures with small environments let rooted = heap.alloc_closure(1, &[Value::Int32(10)]); let unreachable = heap.alloc_closure(2, &[Value::Int32(20)]); // Mark only the rooted one, then sweep. heap.mark_from_roots([rooted]); heap.sweep(); assert!(heap.is_valid(rooted), "rooted object must remain alive after sweep"); assert!( !heap.is_valid(unreachable), "unreachable object must be reclaimed by GC" ); }