From 3fecffee185e9b03913fdfa5b28d083e2e0e212e Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 19 Jul 2021 02:56:36 +0100 Subject: [PATCH] jst-lower: Check that we only do funky stuff if needed Signed-off-by: Ian Jackson --- jstest/jst-lower.rs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/jstest/jst-lower.rs b/jstest/jst-lower.rs index 84a317a7..610c156f 100644 --- a/jstest/jst-lower.rs +++ b/jstest/jst-lower.rs @@ -206,7 +206,7 @@ impl Test { } // no heavy are newly above light - { + let old_misstacked = { let misheavy = |on: &[&PieceCollated]| { let mut misheavy = HashSet::new(); for i in 0..on.len() { @@ -224,7 +224,8 @@ impl Test { let new = misheavy(&new); let newly = new.difference(&old).collect_vec(); assert!( newly.is_empty(), "{:?}", &newly ); - } + old + }; // no light non-targets moved { @@ -279,6 +280,25 @@ impl Test { "{:?} {:?}", &n0, &n1 ); } } + + // non-targets are moved only if they things are funky + { + // funky could be one of: + // - misstacked heavy + // - heavy with same Z Coord (but obvs not Gen) as some light + if old_misstacked.is_empty() && + ! old.iter().tuple_windows().any(|(o0,o1)| { + o0.heavy && ! o1.heavy && + o1.old_z.z == o0.old_z.z + }) + { + for n in &new { + if n.updated { + assert!( n.target, "{:?}", n ); + } + } + } + } } } -- 2.30.2