2022-05-07 20:02:50 +02:00
|
|
|
#![feature(drain_filter)]
|
2022-07-09 22:07:23 +02:00
|
|
|
#![feature(negative_impls)]
|
2022-05-07 20:02:50 +02:00
|
|
|
|
2022-05-16 15:11:41 +02:00
|
|
|
pub mod allocator;
|
|
|
|
pub mod gc_ref;
|
|
|
|
pub mod trace;
|
2022-07-09 22:07:23 +02:00
|
|
|
mod trace_impl;
|
|
|
|
|
|
|
|
// make the test_utils mod pub to use it in fuzzing
|
|
|
|
pub mod test_utils;
|
2022-05-07 20:02:50 +02:00
|
|
|
|
|
|
|
#[cfg(test)]
|
2022-07-09 22:07:23 +02:00
|
|
|
pub(crate) mod tests {
|
2022-05-16 15:11:41 +02:00
|
|
|
use super::allocator::GCAllocator;
|
2022-07-09 22:07:23 +02:00
|
|
|
use super::test_utils::GotDropped;
|
2022-05-07 20:02:50 +02:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn it_works() {
|
2022-07-09 22:07:23 +02:00
|
|
|
let got_dropped = GotDropped::default();
|
2022-05-07 20:02:50 +02:00
|
|
|
|
|
|
|
let mut gc = GCAllocator::default();
|
2022-07-09 22:07:23 +02:00
|
|
|
gc.alloc(got_dropped.make_drop_checker());
|
|
|
|
|
2022-05-16 15:11:41 +02:00
|
|
|
unsafe { gc.gc(&()) };
|
2022-07-09 22:07:23 +02:00
|
|
|
assert!(got_dropped.was_dropped());
|
2022-05-07 20:02:50 +02:00
|
|
|
|
2022-07-09 22:07:23 +02:00
|
|
|
let got_dropped = GotDropped::default();
|
|
|
|
let drop_checker = gc.alloc(got_dropped.make_drop_checker());
|
2022-05-16 15:11:41 +02:00
|
|
|
|
2022-07-09 22:07:23 +02:00
|
|
|
unsafe { gc.gc(&(drop_checker,)) };
|
|
|
|
assert!(!got_dropped.was_dropped());
|
2022-05-16 15:11:41 +02:00
|
|
|
unsafe { gc.gc(&()) };
|
2022-07-09 22:07:23 +02:00
|
|
|
assert!(got_dropped.was_dropped());
|
2022-05-07 20:02:50 +02:00
|
|
|
}
|
|
|
|
}
|