//! A guard inside a loop body, derived and filled. //! //! The regression test for a derivation bug rather than for a feature, and it //! is here because the shape is ordinary: a strip of figures where each may or //! may not report a change is what every dashboard in this tree draws. //! //! `grown` converts the placement it measures in the two-row render into the //! body's own place in the one-row render, and it was subtracting a body length //! from both ends of the window. The earliest placement does not move under //! that conversion -- it is already the body's place -- so the window collapsed //! to a point, and `placed` had nowhere to slide the span when the prefix scan //! ran a byte past the body. `` and `
, } pub(crate) fn cards(n: usize, with_delta: bool) -> Vec { (0..n) .map(|i| Card { value: format!("{i}00"), label: format!("Card {i}"), delta: with_delta.then(|| format!("+{i}%")), }) .collect() } fn delta(card: &Card) -> &str { card.delta.as_deref().unwrap_or_default() } declare! { /// A strip of figures, each of which may report a change. #[staged] pub(crate) shape strip(cards: &[Card]) -> Node; stats [] { for card in cards.iter() { figure Figure::new(card.value.clone(), card.label.clone()) .change(delta(card)) unless card.delta.is_none(); } } } #[cfg(test)] mod tests { use super::*; use quasi_http::Serves as _; use quasi_router::stage::Residual; use quasi_webview::Webview; fn residual() -> Residual { quasi_webview::stage::derive(&Webview::new(), strip_staged) } #[test] fn probe_residual() { let residual = residual(); eprintln!("{:#?}", residual.ops()); } #[test] fn a_guard_inside_a_loop_body_derives() { let webview = Webview::new(); let residual = residual(); for n in [0, 1, 3] { for with in [false, true] { let cards = cards(n, with); assert_eq!( webview.fragment(&strip(&cards)), strip_serve(&residual, &cards), "{n} cards, delta {with}" ); } } } }