use super::*;
use crate::core::AbsoluteRow;
use crate::execution::matching::path::{PathNode, Sym};
fn path_node(row: u64, prev: Option<u32>, depth: u32) -> PathNode {
PathNode {
step: PathStep {
row: AbsoluteRow::new(row),
sym: Sym::User(0),
excluded: false,
},
prev,
depth,
}
}
#[test]
fn deferred_projection_ignores_unobserved_labels_but_preserves_positions() {
let mut arena = vec![path_node(0, None, 1), path_node(1, Some(0), 2)];
let mut alternative = arena[1];
alternative.step.sym = Sym::from_index(2);
arena.push(alternative);
let mut projection = DeferredHistoryProjection::default();
projection.symbols.insert(3);
assert!(projection.equivalent_steps(&arena[1].step, &arena[2].step));
assert_eq!(projection.append_fingerprint(7, &arena[1].step), 7);
projection.symbols.insert(2);
assert!(!projection.equivalent_steps(&arena[1].step, &arena[2].step));
projection.symbols.clear();
projection.exclusions = true;
arena[2].step.excluded = true;
assert!(!projection.equivalent_steps(&arena[1].step, &arena[2].step));
projection.exclusions = false;
projection.all_labels = true;
assert!(!projection.equivalent_steps(&arena[1].step, &arena[2].step));
arena[2].step = arena[1].step;
arena[2].step.row = AbsoluteRow::new(2);
assert_ne!(
projection.append_fingerprint(7, &arena[1].step),
projection.append_fingerprint(7, &arena[2].step)
);
assert!(!projection.equivalent_steps(&arena[1].step, &arena[2].step));
}
#[test]
fn volatile_history_does_not_equate_distinct_occurrences_with_equal_values() {
let step = path_node(0, None, 1).step;
let mut projection = DeferredHistoryProjection::default();
assert!(projection.is_empty());
assert!(projection.equivalent_steps(&step, &step));
projection.extend(&DeferredHistoryProjection {
has_volatile_operations: true,
..Default::default()
});
assert!(!projection.is_empty());
assert!(!projection.equivalent_steps(&step, &step));
}