From: Ian Jackson Date: Sun, 14 Mar 2021 20:08:21 +0000 (+0000) Subject: at: Sort out hidden test which was a bit of a confusion X-Git-Tag: otter-0.4.0~56 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=2162fe4db9ace7a9276148d6166d959868d59480;p=otter.git at: Sort out hidden test which was a bit of a confusion Signed-off-by: Ian Jackson --- diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index 8ef3c1c5..d17e9fe5 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -537,6 +537,8 @@ impl Ctx { let mut a_pieces = alice.pieces::()?; let mut b_pieces = alice.pieces::()?; + // ----- 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(pieces: &PiecesSlice) -> [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 } }