From 1b62f86b8c3f3737fea1dd96aa09e2be3da7cc3d Mon Sep 17 00:00:00 2001 From: Sven Lafebre Date: Fri, 6 Nov 2026 19:57:32 +0100 Subject: [PATCH] Fix #5714: doc comments on the width profile tests --- crates/doc/src/appearance/profile.rs | 3 +++ crates/doc/src/appearance/tests.rs | 1 + crates/effects/src/stroke/tests.rs | 1 + crates/effects/src/stroke/tests_gradient.rs | 2 ++ crates/effects/src/stroke/width.rs | 1 + crates/engine/src/tests/outlinestroke.rs | 1 + crates/engine/src/tests/widthpoints.rs | 1 + 7 files changed, 10 insertions(+) diff --git a/crates/doc/src/appearance/profile.rs b/crates/doc/src/appearance/profile.rs index 0d13dc210..088796173 100644 --- a/crates/doc/src/appearance/profile.rs +++ b/crates/doc/src/appearance/profile.rs @@ -395,6 +395,7 @@ pub struct SavedProfile { mod tests { use super::*; + /// Widths and steps are found by search, at the ends, between points and at a step. #[test] fn width_profile_lookups_by_search() { let p = WidthProfile { points: vec![(0.0, 0.0, 0.0), (0.5, 1.0, 1.0), (0.5, 0.5, 0.25), (1.0, 0.0, 0.0)] }; @@ -441,6 +442,7 @@ mod tests { } } + /// Neither side of a profile goes wider or narrower than the two points of the span it is in. #[test] fn widths_never_pass_the_points_either_side() { for preset in WidthProfile::PRESETS { @@ -474,6 +476,7 @@ mod tests { assert!((p.at(0.25).0 - 2.0).abs() < 1e-12 && (p.at(0.75).0 - 1.5).abs() < 1e-12); } + /// `widest()` is at least the stroke's width anywhere along the profile, even where the sides peak apart. #[test] fn widest_covers_every_width_along_the_profile() { let profiles = [ diff --git a/crates/doc/src/appearance/tests.rs b/crates/doc/src/appearance/tests.rs index ebc491800..c297b3475 100644 --- a/crates/doc/src/appearance/tests.rs +++ b/crates/doc/src/appearance/tests.rs @@ -192,6 +192,7 @@ fn strokes_without_pressure_round_trip_unchanged() { assert_eq!((st.pressure, st.tilt, st.bearing, st.rotation), (None, None, None, None)); } +/// The Lens profile's widths at its middle, a quarter of the way along and past its end. #[test] fn profile_interp() { let p = WidthProfile::lens(); diff --git a/crates/effects/src/stroke/tests.rs b/crates/effects/src/stroke/tests.rs index dbe271cd8..46969ff63 100644 --- a/crates/effects/src/stroke/tests.rs +++ b/crates/effects/src/stroke/tests.rs @@ -225,6 +225,7 @@ fn expand_stroke_region_of_a_round_line_stays_compact() { assert_eq!(dense_anchors, anchors, "colinear spine points should not add outline anchors"); } +/// A line's outline takes its width profile, its dashes (each reading the profile where it sits) or neither. #[test] fn line_outline_uses_the_profile_dashes_or_a_plain_stroke() { let l = line(0.0, 100.0); diff --git a/crates/effects/src/stroke/tests_gradient.rs b/crates/effects/src/stroke/tests_gradient.rs index b4ffc0573..489182406 100644 --- a/crates/effects/src/stroke/tests_gradient.rs +++ b/crates/effects/src/stroke/tests_gradient.rs @@ -117,6 +117,7 @@ fn along_keeps_a_corners_colour_round_its_outside() { assert!((param(&sl, Point::new(95.0, 8.0)).unwrap() - 0.54).abs() < 1e-6); } +/// An Across stroke gradient runs from the stroke's left edge to its right edge, also where a width profile moves them. #[test] fn across_runs_from_the_left_edge_to_the_right() { let st = stroke(10.0, StrokeGradientMode::Across); @@ -163,6 +164,7 @@ fn an_aligned_stroke_spans_the_gradient_across_the_side_it_shows_on() { } } +/// The gradient slices cover every point the stroke paints, with each join, caps, arrowheads, a profile and dashes. #[test] fn slices_cover_everything_the_stroke_paints() { let zig = poly(&[(0.0, 0.0), (60.0, 40.0), (0.0, 80.0), (70.0, 90.0), (75.0, 20.0)], false); diff --git a/crates/effects/src/stroke/width.rs b/crates/effects/src/stroke/width.rs index bcaedc831..4a9dc2678 100644 --- a/crates/effects/src/stroke/width.rs +++ b/crates/effects/src/stroke/width.rs @@ -423,6 +423,7 @@ mod tests { assert!((area(&width_outline(&line(), 10.0, &p, &capped(LineCap::Square), 0.01)) - 1100.0).abs() < 1e-6); } + /// The Lens outline swells on its curve, and a profile with one side at zero paints only the other side. #[test] fn lens_profile_swells_smoothly_and_one_sided_profiles_stay_on_their_side() { // Each half of the lens rises on a cubic from 0 to full width, flat at the middle: it diff --git a/crates/engine/src/tests/outlinestroke.rs b/crates/engine/src/tests/outlinestroke.rs index 926bee91b..955e9798e 100644 --- a/crates/engine/src/tests/outlinestroke.rs +++ b/crates/engine/src/tests/outlinestroke.rs @@ -71,6 +71,7 @@ fn arrowheads_are_part_of_the_outline() { assert_eq!(path_of(&n).subpaths.len(), 1, "line and head are one shape"); } +/// Outline Stroke of a Lens-profile line covers 7/12 of the full-width rectangle. #[test] fn a_lens_profile_outlines_to_seven_twelfths_of_the_rectangle() { let mut s = session(); diff --git a/crates/engine/src/tests/widthpoints.rs b/crates/engine/src/tests/widthpoints.rs index fc2b21568..4c837c300 100644 --- a/crates/engine/src/tests/widthpoints.rs +++ b/crates/engine/src/tests/widthpoints.rs @@ -214,6 +214,7 @@ fn new_width_point_without_adjoining_preserves_neighbours() { new_point_adjoining(false); } +/// A new width point with Adjust Adjoining scales only its nearest neighbours, by the widths sampled where it goes. #[test] fn new_width_point_adjust_adjoining_uses_sampled_widths() { for indexed in [false, true] {