From: Ian Jackson Date: Mon, 19 Jul 2021 01:56:36 +0000 (+0100) Subject: jst-lower: Check that we only do funky stuff if needed X-Git-Tag: otter-0.7.2~23 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=3fecffee185e9b03913fdfa5b28d083e2e0e212e;p=otter.git jst-lower: Check that we only do funky stuff if needed Signed-off-by: Ian Jackson --- 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 ); + } + } + } + } } }