crate::ix!();
#[cfg(test)]
mod epoch_deduplication_behavior {
use super::*;
#[traced_test]
fn first_then_second_visit() {
let epoch = Rc::new(RefCell::new(Epoch::default()));
let _guard = EpochGuard::new(epoch.clone());
let mut marker = EpochMarker::default();
assert!(!epoch.borrow().visited(&mut marker));
assert!( epoch.borrow().visited(&mut marker));
}
#[traced_test]
fn guard_drop_resets_state() {
let epoch = Rc::new(RefCell::new(Epoch::default()));
{
let _guard = EpochGuard::new(epoch.clone());
assert!(epoch.borrow().guarded());
}
assert!(!epoch.borrow().guarded());
{
let _guard = EpochGuard::new(epoch.clone());
let mut marker = EpochMarker::default();
assert!(!epoch.borrow().visited(&mut marker));
}
}
#[traced_test]
fn macro_creates_and_drops_guard() {
let epoch = Rc::new(RefCell::new(Epoch::default()));
{
with_fresh_epoch!(epoch);
assert!(epoch.borrow().guarded());
}
assert!(!epoch.borrow().guarded());
}
#[test]
#[should_panic(expected = "nested EpochGuard")]
fn nested_guard_panics() {
let epoch = Rc::new(RefCell::new(Epoch::default()));
let _g1 = EpochGuard::new(epoch.clone());
let _g2 = EpochGuard::new(epoch); }
}