diff --git a/context/test-evidence/command.md b/context/test-evidence/command.md index c042f940..fff91837 100644 --- a/context/test-evidence/command.md +++ b/context/test-evidence/command.md @@ -227,6 +227,14 @@ checked by adding a `probe_field` to `Model` and to `Model::new`. The build then failed with `E0027: pattern does not mention field probe_field` at the `Debug` impl, and nowhere else. +**`Model.measure_agg` needed the same treatment (improvise-m6op).** `Model`'s +`Debug` sorts `measure_agg` through a `BTreeMap`, but the fixture's +`measure_agg` was empty, so nothing saw the sort. With the sort replaced by the +raw `HashMap` (`.field("measure_agg", &measure_agg)`), this test stayed green in +3 of 3 runs. The fixture now carries four entries: `Revenue` Avg, `Cost` Min, +`Units` Max and `Orders` Count. Under the same injection it is red in 3 of 3 +runs, and it is green with the sort restored. + ### a_stale_wire_model_command_cannot_be_applied A wire `Command::Model` cannot reach the document without its basis being checked diff --git a/crates/improvise-command/src/ui/reduce.rs b/crates/improvise-command/src/ui/reduce.rs index a598f68b..4cbf2fe6 100644 --- a/crates/improvise-command/src/ui/reduce.rs +++ b/crates/improvise-command/src/ui/reduce.rs @@ -959,6 +959,16 @@ pub(crate) mod tests { ]); wb.model.set_cell(key, CellValue::Number(n as f64 + 1.0)); } + // Several entries, so two instances' HashMaps can disagree on order (improvise-m6op). + use crate::formula::AggFunc; + for (measure, agg) in [ + ("Revenue", AggFunc::Avg), + ("Cost", AggFunc::Min), + ("Units", AggFunc::Max), + ("Orders", AggFunc::Count), + ] { + wb.model.measure_agg.insert(measure.into(), agg); + } let view = wb.active_view_mut(); view.set_axis("Region", Axis::Row); view.set_axis("Month", Axis::Column);