chiark / gitweb /
at: Sort out hidden test which was a bit of a confusion
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 14 Mar 2021 20:08:21 +0000 (20:08 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 14 Mar 2021 20:08:21 +0000 (20:08 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
apitest/at-otter.rs

index 8ef3c1c52f56a67f53daf0b3bc8521f19bd16b5f..d17e9fe50ba6eb01c42348449ac65377b91fbe02 100644 (file)
@@ -537,6 +537,8 @@ impl Ctx {
     let mut a_pieces = alice.pieces::<PIA>()?;
     let mut b_pieces = alice.pieces::<PIB>()?;
 
+    // ----- alice: claim alices' hand -----
+
     let [hand] = a_pieces.iter_enumerated()
       .filter(|(i,p)| p.info["desc"] == otter::hand::UNCLAIMED_DESC)
       .map(|(i,_)| i)
@@ -549,6 +551,8 @@ impl Ctx {
       "wrc": "Unpredictable",
     })))?;
 
+    // ----- find the pawns -----
+
     fn find_pawns<PI:Idx>(pieces: &PiecesSlice<PI>) -> [PI; 2] {
       let mut pawns = pieces.iter_enumerated()
         .filter(|(i,p)| p.info["desc"].as_str().unwrap().ends_with(" pawn"))
@@ -567,6 +571,8 @@ impl Ctx {
 
     bob.synch()?;
 
+    // ----- alice: move pawns into alice's hand -----
+
     for (&pawn, &xoffset) in izip!(&a_pawns, [10,20].iter()) {
       let pos = (a_pieces[hand].pos + PosC([xoffset, 0]))?;
       alice.api_piece(GH::With, (&mut a_pieces, pawn), pos)?;
@@ -581,6 +587,8 @@ impl Ctx {
       assert_eq!(got, None);
     }
 
+    // ----- alice: move one pawn within alice's hand -----
+
     {
       let p = a_pawns[0];
       let alice_move_to = (a_pieces[p].pos + PosC([5, 5]))?;
@@ -600,26 +608,16 @@ impl Ctx {
       bob.synchu(&mut b_pieces)?;
     }
 
-    for (xi, &p) in a_pawns.iter().enumerate().take(1) {
-      let xix: Coord = xi.try_into().unwrap();
-      let pos = PosC([ (xix + 1) * 15, 20 ]);
-      alice.api_piece(GH::With, (&mut a_pieces, p), pos)?;
-    }
+    // ----- alice: move one pawn out of alice's hand -----
+
+    alice.api_piece(GH::With,
+                    (&mut a_pieces, a_pawns[0]),
+                    PosC([ 15, 20 ]))?;
 
     alice.synchu(&mut a_pieces)?;
     bob.synchu(&mut b_pieces)?;
     assert_eq!(b_pieces[b_pawns[1]].pos,
                a_pieces[a_pawns[0]].pos);
-
-    let out_again = (a_pieces[hand].pos + PosC([5, 0]))?;
-    for (xi, &p) in a_pawns.iter().enumerate().take(1) {
-      alice.api_piece(GH::With, (&mut a_pieces, p), out_again)?;
-    }
-
-    alice.synchu(&mut a_pieces)?;
-    bob.synchu(&mut b_pieces)?;
-
-    // xxx check that the right thing happened
   }
 }