chiark / gitweb /
jst-lower: Check that we only do funky stuff if needed
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 19 Jul 2021 01:56:36 +0000 (02:56 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 19 Jul 2021 23:45:27 +0000 (00:45 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
jstest/jst-lower.rs

index 84a317a7db5cf5eb1aca1bf60b7850f0fffb08a8..610c156fc5db1f3cc73e2ddb7886f8c50b328dad 100644 (file)
@@ -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 );
+          }
+        }
+      }
+    }
   }
 }