From e4c1ffa4f12215954f8d83a0e230eb4b0276d0f2 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 16 Oct 2026 01:24:20 +0200 Subject: [PATCH] cultmath: span tests: a zero-length span through the sloped branch is +0 by bit pattern Stryker survivor on the previous head: direction t1 <= t0 changes a zero-length sloped span from +0 to -0, which no test observed. Builds; test-only. Co-Authored-By: Claude Sonnet 5.5 --- .../cultmath/tests/CultMath.Tests/SpanPrimitiveTests.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/cultmath/tests/CultMath.Tests/SpanPrimitiveTests.cs b/packages/cultmath/tests/CultMath.Tests/SpanPrimitiveTests.cs index 022a17cb..dea5ab0c 100644 --- a/packages/cultmath/tests/CultMath.Tests/SpanPrimitiveTests.cs +++ b/packages/cultmath/tests/CultMath.Tests/SpanPrimitiveTests.cs @@ -322,7 +322,7 @@ public sealed class SpanPrimitiveTests /// /// An infinite bound never reached by the line contributes nothing, not infinity times zero: relu /// (hi = +inf) and its mirror (lo = -inf) give the finite integral, whether the line crosses the finite - /// bound inside the span or not. The flat branch (b = 0) obeys the same zero-length rule. + /// bound inside the span or not. Both branches give +0 for a zero-length span. /// [Fact] public void IntegralClampLinearIsFiniteForInfiniteBounds() @@ -352,6 +352,12 @@ public sealed class SpanPrimitiveTests Assert.Equal(0, BitConverter.SingleToInt32Bits(integral_clamp_linear(1.5f, -0.0f, -inf, -inf, 0.0f, 0.0f))); Assert.Equal(inf, integral_clamp_linear(1.5f, 0.0f, inf, inf, 0.0f, 2.0f)); Assert.Equal(inf, integral_clamp_linear(1.5f, 0.0f, -inf, -inf, 2.0f, 0.0f)); + + // The sloped branch gives +0 for a zero-length span too, not -0: the direction sign never meets a + // zero total, whichever way the line leans and whatever the bounds. + Assert.Equal(0, BitConverter.SingleToInt32Bits(integral_clamp_linear(1.0f, 2.0f, -inf, inf, 1.0f, 1.0f))); + Assert.Equal(0, BitConverter.SingleToInt32Bits(integral_clamp_linear(-3.0f, -2.0f, 0.0f, 5.0f, 1.0f, 1.0f))); + Assert.Equal(0, BitConverter.SingleToInt32Bits(integral_clamp_linear(0.5f, 1.0f, 0.0f, inf, 0.0f, 0.0f))); } ///