M8: review on #1583: the too-large margin test asserts the capped sum

The test only checked for a large finite margin, which the old largest-effect margin (1e308) passed as well. It now asserts the two capped reaches added up, so it fails on a return to either the old maximum or an overflowing sum.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
samhyun
2026-10-30 09:13:26 +09:00
co-authored by Claude Opus 5.5
parent be9223a9ed
commit 872c85bf7d
2 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -474,7 +474,7 @@ pub(crate) fn bounds_within<'a>(
/// The most one effect counts for in [`effect_margin`] (document units): far past any view, and
/// sums of any number of them stay finite.
const MAX_REACH: f64 = 1e12;
pub(crate) const MAX_REACH: f64 = 1e12;
/// How far (document units) effects that read outside a node's paint bounds reach: blurs, glass,
/// drop shadows and texture. Culling and partial renders keep this much margin.
+3 -2
View File
@@ -436,14 +436,15 @@ fn a_shadow_cast_from_a_blurred_layer_draws_the_same_in_a_cut_view() {
assert_within(&part, &one, 390, 2, "the shadow of a blurred layer above the view");
}
/// Reaches too large to add (texture of 1e308, twice) still keep a margin, not none.
/// Reaches too large to add (texture of 1e308, twice) each count up to the cap and add up: a margin
/// that stays finite, not none, and not the largest one alone.
#[test]
fn effect_margins_too_large_to_add_stay_large() {
let mut n = Node::new(NodeId(1), NodeKind::Rectangle, "T", 10.0, 10.0);
let t = figcraft_doc::Texture { radius: 1e308, ..Default::default() };
n.effects = vec![Effect { kind: EffectKind::Texture(t.clone()), visible: true }, Effect { kind: EffectKind::Texture(t), visible: true }];
let m = crate::draw::effect_margin(&n);
assert!(m.is_finite() && m > 1e6, "{m}");
assert_eq!(m, 2.0 * crate::draw::MAX_REACH);
}
/// Every channel of `a` within `tol` of the same channel of `b` from row `rows_down` on.