diff --git a/crates/aura-cli/src/diag.rs b/crates/aura-cli/src/diag.rs index d3cedb6..1be3c04 100644 --- a/crates/aura-cli/src/diag.rs +++ b/crates/aura-cli/src/diag.rs @@ -19,6 +19,19 @@ macro_rules! warning { pub(crate) use {note, warning}; +/// The zero-trade note's message text (#313), pluralization-aware — the +/// milestone fieldtest tripped over "all 1 walk-forward windows" +/// (captured: `fieldtests/milestone-stderr-honesty/captured/ +/// example2_singular.err`). Pure over the count so the wording is +/// unit-pinned. +fn zero_trade_note_text(n_windows: usize) -> String { + if n_windows == 1 { + "the single walk-forward window recorded zero trades".to_string() + } else { + format!("all {n_windows} walk-forward windows recorded zero trades") + } +} + /// The #313 zero-trade note, shared by both walk-forward paths (the /// synthetic-blueprint path in `main.rs` and the `--real` sugar path in /// `verb_sugar.rs`) so the wording AND the condition live in exactly one @@ -27,6 +40,26 @@ pub(crate) use {note, warning}; pub(crate) fn note_zero_trade_windows(mut window_trades: impl ExactSizeIterator) { let n_windows = window_trades.len(); if n_windows > 0 && window_trades.all(|n| n == 0) { - note!("all {n_windows} walk-forward windows recorded zero trades"); + note!("{}", zero_trade_note_text(n_windows)); + } +} + +#[cfg(test)] +mod tests { + use super::zero_trade_note_text; + + #[test] + /// #278 fieldtest friction: the single-window form must read as + /// grammatical English while the plural form keeps the exact phrase + /// the e2e pins grep for. + fn zero_trade_note_pluralizes() { + assert_eq!( + zero_trade_note_text(1), + "the single walk-forward window recorded zero trades" + ); + assert_eq!( + zero_trade_note_text(3), + "all 3 walk-forward windows recorded zero trades" + ); } }