From 332e115b68e97032010d2796d56050718edd86a3 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 7 Nov 2026 20:10:31 -0800 Subject: [PATCH] Plug-ins: the bulk memory fuzz generators follow the paint generators Moves the bulk memory case types, strategies and their test after arb_paint, so they no longer share the lines after output where other fuzz generators are added. --- crates/engine/tests/plugin_fuzz.rs | 104 ++++++++++++++--------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/crates/engine/tests/plugin_fuzz.rs b/crates/engine/tests/plugin_fuzz.rs index 01f5e154e..514118cf3 100644 --- a/crates/engine/tests/plugin_fuzz.rs +++ b/crates/engine/tests/plugin_fuzz.rs @@ -160,58 +160,6 @@ fn arb_paint() -> impl Strategy { ] } -/// An output object: an input object's id (by index into the inputs) or a random one, and any of -/// the object keys. -fn arb_object() -> impl Strategy, Value)> { - let stroke = (arb_paint(), prop::option::of(arb_num())).prop_map(|(p, w)| json!({"paint": p, "width": w})); - ( - prop::option::of(0usize..8), - prop::option::of(prop_oneof![Just(json!("path")), Just(json!("compound")), arb_junk()]), - prop::option::of(arb_path()), - prop::option::of(prop_oneof![Just(json!("evenodd")), Just(json!("nonzero")), arb_junk()]), - prop::option::of(prop::collection::vec(arb_paint(), 0..3)), - prop::option::of(prop::collection::vec(stroke, 0..3)), - prop::option::of(arb_num()), - prop::option::of(prop_oneof![Just(json!("name")), arb_junk()]), - ) - .prop_map(|(id, t, path, rule, fills, strokes, opacity, name)| { - let mut o = Map::new(); - for (k, v) in [ - ("type", t), - ("path", path), - ("fillRule", rule), - ("fills", fills.map(Value::from)), - ("strokes", strokes.map(Value::from)), - ("opacity", opacity), - ("name", name), - ] { - if let Some(v) = v { - o.insert(k.into(), v); - } - } - (id, Value::Object(o)) - }) -} - -/// The output document: objects (ids resolved against `inputs`; out-of-range indices become -/// unknown ids), or junk. -fn output(objects: &[(Option, Value)], inputs: &[u64], junk: Option) -> String { - if let Some(j) = junk { - return j.to_string(); - } - let list: Vec = objects - .iter() - .map(|(id, o)| { - let mut o = o.clone(); - if let Some(i) = id { - o["id"] = json!(inputs.get(*i).copied().unwrap_or(9_999_999 + *i as u64)); - } - o - }) - .collect(); - json!({ "objects": list }).to_string() -} - /// Bytes in the passive data segment that bulk memory cases initialize memory from. const SEGMENT_LEN: u32 = 4096; @@ -478,6 +426,58 @@ fn bulk_memory_cases_reach_their_instruction() { } } +/// An output object: an input object's id (by index into the inputs) or a random one, and any of +/// the object keys. +fn arb_object() -> impl Strategy, Value)> { + let stroke = (arb_paint(), prop::option::of(arb_num())).prop_map(|(p, w)| json!({"paint": p, "width": w})); + ( + prop::option::of(0usize..8), + prop::option::of(prop_oneof![Just(json!("path")), Just(json!("compound")), arb_junk()]), + prop::option::of(arb_path()), + prop::option::of(prop_oneof![Just(json!("evenodd")), Just(json!("nonzero")), arb_junk()]), + prop::option::of(prop::collection::vec(arb_paint(), 0..3)), + prop::option::of(prop::collection::vec(stroke, 0..3)), + prop::option::of(arb_num()), + prop::option::of(prop_oneof![Just(json!("name")), arb_junk()]), + ) + .prop_map(|(id, t, path, rule, fills, strokes, opacity, name)| { + let mut o = Map::new(); + for (k, v) in [ + ("type", t), + ("path", path), + ("fillRule", rule), + ("fills", fills.map(Value::from)), + ("strokes", strokes.map(Value::from)), + ("opacity", opacity), + ("name", name), + ] { + if let Some(v) = v { + o.insert(k.into(), v); + } + } + (id, Value::Object(o)) + }) +} + +/// The output document: objects (ids resolved against `inputs`; out-of-range indices become +/// unknown ids), or junk. +fn output(objects: &[(Option, Value)], inputs: &[u64], junk: Option) -> String { + if let Some(j) = junk { + return j.to_string(); + } + let list: Vec = objects + .iter() + .map(|(id, o)| { + let mut o = o.clone(); + if let Some(i) = id { + o["id"] = json!(inputs.get(*i).copied().unwrap_or(9_999_999 + *i as u64)); + } + o + }) + .collect(); + json!({ "objects": list }).to_string() +} + proptest! { #![proptest_config(config())]