From 1f80c018c7c149ecba6f625fe6775d0777b8067a Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Mon, 2 Nov 2026 21:03:30 -0500 Subject: [PATCH] Gradients: compare NaN samples as printed in the stop lookup test --- crates/color/src/gradient/tests.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/color/src/gradient/tests.rs b/crates/color/src/gradient/tests.rs index 7084be18c..6c9a08a9d 100644 --- a/crates/color/src/gradient/tests.rs +++ b/crates/color/src/gradient/tests.rs @@ -41,7 +41,9 @@ fn stop_reach_matches_scanning_the_stops() { let g = Gradient::new(GradientKind::Linear, stops); let reach = StopReach::new(&g.stops); for t in (-4..=44).map(|k| k as f32 / 40.0).chain([f32::NAN, f32::INFINITY, f32::NEG_INFINITY]) { - assert_eq!(reach.sample_with(&g.stops, t, &Color::lerp_keep_model), g.sample_with(t, Color::lerp_keep_model), "{offsets:?} at {t}"); + // Compared as printed: a NaN offset mixes NaN colours, which are equal only so. + let (got, want) = (reach.sample_with(&g.stops, t, &Color::lerp_keep_model), g.sample_with(t, Color::lerp_keep_model)); + assert_eq!(format!("{got:?}"), format!("{want:?}"), "{offsets:?} at {t}"); } } }