From: Ian Jackson Date: Sun, 24 Apr 2022 15:25:19 +0000 (+0100) Subject: tests: at-hidden: wip test X-Git-Tag: otter-1.1.0~455 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=e611b7fdb587de6beea2b733b8296d5e1697c0d3;p=otter.git tests: at-hidden: wip test This currently passes, and therefore didn't repro the un-notched piece bug which I have been trying to repro and fix. But it's a start. Signed-off-by: Ian Jackson --- diff --git a/apitest/at-hidden.rs b/apitest/at-hidden.rs new file mode 100644 index 00000000..24883266 --- /dev/null +++ b/apitest/at-hidden.rs @@ -0,0 +1,51 @@ +// Copyright 2020-2021 Ian Jackson and contributors to Otter +// SPDX-License-Identifier: AGPL-3.0-or-later +// There is NO WARRANTY. + +#![allow(dead_code)] +#![allow(unused_mut)] +#![allow(unused_variables)] + +use crate::*; + +type Ctx = UsualCtx; + +impl Ctx { + #[throws(Explode)] + fn dice(&mut self) { + self.otter_resetting(&G("reset demo"))?; + + let mut alice = self.connect_player(&self.alice)?; + let mut bob = self.connect_player(&self.bob)?; + + let mut a_pieces = alice.pieces::()?; + let hand = a_pieces.find_by_desc_glob(otter::hand::UNCLAIMED_HAND_DESC); + let hand_pos = a_pieces[hand].pos; + let die_a = a_pieces.find_by_desc_glob("a d2 *"); + let die_red = a_pieces.find_by_desc_glob("a d2 *"); + + let move_into_hand = |alice: &mut Session, a_pieces: &'_ mut _, p, x_off| { + let pos = (hand_pos + PosC::new(x_off,0))?; + alice.api_piece(GH::With, PuSynch(&mut (a_pieces, p)), pos)?; + Ok::<_,Explode>(()) + }; + move_into_hand(&mut alice, &mut a_pieces, die_a, -10)?; + + alice.api_piece(GH::With, PuSynch(&mut (&mut a_pieces, hand)), + ("k", json!({ "opname": "claim", + "wrc": WRC::Unpredictable })))?; + move_into_hand(&mut alice, &mut a_pieces, die_a, 10)?; + + // TODO rest of this test + } +} + +#[throws(Explode)] +fn tests(mut c: Ctx) { + test!(c, "dice", c.dice() ?); +} + +#[throws(Explode)] +pub fn main() { + tests(Ctx::setup()?)?; +} diff --git a/apitest/atmain.rs b/apitest/atmain.rs index 6deb69b2..9ce5b36e 100644 --- a/apitest/atmain.rs +++ b/apitest/atmain.rs @@ -686,6 +686,7 @@ impl UsualCtx { portmanteau_has!("at-otter.rs", at_otter); portmanteau_has!("at-bundles.rs", at_bundles); +portmanteau_has!("at-hidden.rs", at_hidden); #[throws(AE)] fn main() { portmanteau_main("at")? }