chiark / gitweb /
currency: wip test
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 18 Apr 2022 15:32:20 +0000 (16:32 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 30 Apr 2022 14:15:30 +0000 (15:15 +0100)
So far we test that splitting appears to succeed, but not what the
results look like.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
apitest/at-currency.rs [new file with mode: 0644]
apitest/atmain.rs

diff --git a/apitest/at-currency.rs b/apitest/at-currency.rs
new file mode 100644 (file)
index 0000000..d54bc3d
--- /dev/null
@@ -0,0 +1,41 @@
+// Copyright 2020-2021 Ian Jackson and contributors to Otter
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// There is NO WARRANTY.
+
+use crate::*;
+
+type Ctx = UsualCtx;
+
+impl Ctx {
+  #[throws(Explode)]
+  fn multigrab(&mut self) {
+    let mut alice = self.connect_player(&self.alice)?;
+    let mut a_pieces = alice.pieces::<PIA>()?;
+
+    let [bn] = a_pieces.iter_enumerated()
+      .filter_map(|(i,p)| {
+        if ! p.info["desc"].as_str()?.contains("400") { return None }
+        Some(i)
+      })
+      .collect::<ArrayVec<_,1>>()
+      .into_inner().unwrap();
+
+    let other_pile = [40,20];
+    alice.api_piece_op_single(PuSynch((&mut a_pieces, bn)).id(), (
+      "multigrab", json!({ "n": 50, 'z': "q000000000" })
+    ))?;
+    alice.synch()?;
+
+    let _ = other_pile;
+  }
+}
+
+#[throws(Explode)]
+fn tests(mut c: Ctx) {
+  test!(c, "multigrab",                     c.multigrab()              ?);
+}
+
+#[throws(Explode)]
+pub fn main() {
+  tests(Ctx::setup()?)?;
+}
index a6cbc9fa66e4695a8289f004847389ca72cafc20..1f663bddb0aeecf31458b44e159ccd4020a4d796 100644 (file)
@@ -687,6 +687,7 @@ impl UsualCtx {
 portmanteau_has!("at-otter.rs",   at_otter);
 portmanteau_has!("at-bundles.rs", at_bundles);
 portmanteau_has!("at-hidden.rs",  at_hidden);
+portmanteau_has!("at-currency.rs", at_currency);
 
 #[throws(AE)]
 fn main() { portmanteau_main("at")? }