crftng-intrprtrs/gc/src/lib.rs

37 lines
799 B
Rust

#![feature(drain_filter)]
#![feature(negative_impls)]
pub mod allocator;
pub mod gc_ref;
pub mod trace;
mod trace_impl;
// make the test_utils mod pub to use it in fuzzing
pub mod test_utils;
#[cfg(test)]
pub(crate) mod tests {
use super::allocator::GCAllocator;
use super::test_utils::GotDropped;
#[test]
fn gc_allocates_and_frees_structs() {
let got_dropped = GotDropped::default();
let mut gc = GCAllocator::default();
gc.alloc(got_dropped.make_drop_checker());
unsafe { gc.gc(&()) };
assert!(got_dropped.was_dropped());
let got_dropped = GotDropped::default();
let drop_checker = gc.alloc(got_dropped.make_drop_checker());
unsafe { gc.gc(&(drop_checker,)) };
assert!(!got_dropped.was_dropped());
unsafe { gc.gc(&()) };
assert!(got_dropped.was_dropped());
}
}