chiark / gitweb /
jstest: lower: Make Test::pieces be an IndexMap
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 9 Jul 2021 11:12:51 +0000 (12:12 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 9 Jul 2021 11:14:02 +0000 (12:14 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Cargo.lock
jstest/Cargo.toml
jstest/jst-lower.rs

index be9cdf3d2987785f03943c0cc668d0b11ebbce4e..7d26738888c6e21ab9ed1a8eb0b39a50063db861 100644 (file)
@@ -1720,6 +1720,7 @@ checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3"
 dependencies = [
  "autocfg 1.0.1",
  "hashbrown",
+ "serde",
 ]
 
 [[package]]
index d2ea72711e85c56cc23e0bbe057b258d0b5e9754..3167a88a15dd3cbdff00377ad4216ed5c6c44442 100644 (file)
@@ -32,7 +32,7 @@ otter.version="=0.7.1"
 otter-api-tests.path="../apitest"
 otter-api-tests.version="=0.7.1"
 
-indexmap = "1.6"
+indexmap = { version = "1.6", features=["serde"] }
 
 fehler="1"
 structopt="0.3"
index a48a6a0fc29da77a6e9f177ec7f18b0869e9a923..46fc8e9daf02fa09d53b844c1eb4c7820d8eeea0 100644 (file)
@@ -44,7 +44,8 @@ pub struct Tests {
 #[derive(Serialize)]
 pub struct Test {
   name: String,
-  pieces: Vec<StartPiece>,
+  #[serde(with = "indexmap::serde_seq")]
+  pieces: IndexMap<VisiblePieceId, StartPiece>,
   targets: Vec<VisiblePieceId>,
 }
 
@@ -88,10 +89,10 @@ jstest_did = fs.openSync('{{ name }}.did', 'w');
 
 pieces = {
 {% for p in pieces -%}
-  '{{ p.id }}': {
-    pinned: {{ p.pinned }},
-    moveable: '{{ p.moveable }}',
-    z: '{{ p.z }}',
+  '{{ p.0 }}': {
+    pinned: {{ p.1.pinned }},
+    moveable: '{{ p.1.moveable }}',
+    z: '{{ p.1.z }}',
   },
 {% endfor -%}
 }
@@ -99,7 +100,7 @@ pieces = {
 fake_dom = [
   { special: "pieces_marker", dataset: { } },
 {% for p in pieces -%}
-  { dataset: { piece: "{{ p.id }}" } },
+  { dataset: { piece: "{{ p.0 }}" } },
 {% endfor -%}
   { special: "defs_marker", dataset: { } },
 ];
@@ -161,9 +162,9 @@ impl TestsAccumulator {
       |StartPieceSpec { id, pinned, moveable }| {
         let id = id.try_into().unwrap();
         let z = zm.increment().unwrap();
-        StartPiece { id, pinned, moveable, z }
+        (id, StartPiece { id, pinned, moveable, z })
       }
-    ).collect_vec();
+    ).collect();
 
     let targets = targets.into_iter().map(
       |s| s.try_into().unwrap()