From eeb67e2a2237493f2bab33da51f81d70a2a26887 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 24 Sep 2026 19:44:58 +0200 Subject: [PATCH] Add tied-value comparisons to kill boundary-flip mutants for real The no-tie fixture in each *ComparisonOperatorsDifferPerComponent test correctly kills direction mutations (< swapped for >) but leaves every strict/non-strict boundary swap (< to <=, > to >=) surviving, since with no equal component the two behave identically. That default is appropriate for a float-threshold epsilon check, but these are general-purpose vector comparison operators (CultMath's own RectIntersectionTreatsTouchingEdgesAsContact test compares literal endpoints), and for the int types an exact tie is the routine case, not the rare one. Add a complementary "compared against itself" call per type (vector-vector for double2/double3/int2/int3/int4, plus vector-scalar and scalar-vector for float2/float3/float4) so every component ties and the boundary swaps are actually exercised. Co-Authored-By: Claude Opus 5.5 --- .../CultMath.Tests/VectorEqualityTests.cs | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/packages/cultmath/tests/CultMath.Tests/VectorEqualityTests.cs b/packages/cultmath/tests/CultMath.Tests/VectorEqualityTests.cs index e23547ee..53fca558 100644 --- a/packages/cultmath/tests/CultMath.Tests/VectorEqualityTests.cs +++ b/packages/cultmath/tests/CultMath.Tests/VectorEqualityTests.cs @@ -119,6 +119,17 @@ public sealed class VectorEqualityTests AssertElementwiseComparisonOperators( scalar, left, new double[] { scalar, scalar }, leftVals, (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "float2 scalar-vector"); + + // A value compared against an exact copy of itself: every component ties. This is the + // complementary fixture to the no-tie one above. A tie is where < and <= (or > and >=) + // actually disagree, so it catches a strict/non-strict boundary swap (e.g. < mutated to + // <=) that a fixture with no equal components cannot: unlike a threshold compared against + // an arbitrary float, an exact self-tie is neither rare nor equivalent here, since these + // are general-purpose comparison operators (bounds/containment checks compare against + // literal endpoints routinely, as CultMath's own touching-edges rect test does). + AssertElementwiseComparisonOperators( + left, left, leftVals, leftVals, + (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "float2 tied vector-vector"); } // ---- float3 ----------------------------------------------------------------------------- @@ -166,6 +177,11 @@ public sealed class VectorEqualityTests AssertElementwiseComparisonOperators( scalar, left, new double[] { scalar, scalar, scalar }, leftVals, (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "float3 scalar-vector"); + + // Tied against itself (see the float2 tied-fixture comment above). + AssertElementwiseComparisonOperators( + left, left, leftVals, leftVals, + (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "float3 tied vector-vector"); } // ---- float4 ----------------------------------------------------------------------------- @@ -214,6 +230,11 @@ public sealed class VectorEqualityTests AssertElementwiseComparisonOperators( scalar, left, new double[] { scalar, scalar, scalar, scalar }, leftVals, (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "float4 scalar-vector"); + + // Tied against itself (see the float2 tied-fixture comment above). + AssertElementwiseComparisonOperators( + left, left, leftVals, leftVals, + (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "float4 tied vector-vector"); } // ---- double2 ---------------------------------------------------------------------------- @@ -244,6 +265,11 @@ public sealed class VectorEqualityTests AssertElementwiseComparisonOperators( left, right, leftVals, rightVals, (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "double2 vector-vector"); + + // Tied against itself (see the float2 tied-fixture comment above). + AssertElementwiseComparisonOperators( + left, left, leftVals, leftVals, + (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "double2 tied vector-vector"); } // ---- double3 ---------------------------------------------------------------------------- @@ -276,6 +302,11 @@ public sealed class VectorEqualityTests AssertElementwiseComparisonOperators( left, right, leftVals, rightVals, (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "double3 vector-vector"); + + // Tied against itself (see the float2 tied-fixture comment above). + AssertElementwiseComparisonOperators( + left, left, leftVals, leftVals, + (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "double3 tied vector-vector"); } // ---- int2 ------------------------------------------------------------------------------- @@ -306,6 +337,12 @@ public sealed class VectorEqualityTests AssertElementwiseComparisonOperators( left, right, leftVals, rightVals, (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "int2 vector-vector"); + + // Tied against itself (see the float2 tied-fixture comment above); integers make an + // exact tie the routine case, not the rare one. + AssertElementwiseComparisonOperators( + left, left, leftVals, leftVals, + (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "int2 tied vector-vector"); } // ---- int3 ------------------------------------------------------------------------------- @@ -338,6 +375,11 @@ public sealed class VectorEqualityTests AssertElementwiseComparisonOperators( left, right, leftVals, rightVals, (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "int3 vector-vector"); + + // Tied against itself (see the int2 tied-fixture comment above). + AssertElementwiseComparisonOperators( + left, left, leftVals, leftVals, + (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "int3 tied vector-vector"); } // ---- int4 ------------------------------------------------------------------------------- @@ -371,6 +413,11 @@ public sealed class VectorEqualityTests AssertElementwiseComparisonOperators( left, right, leftVals, rightVals, (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "int4 vector-vector"); + + // Tied against itself (see the int2 tied-fixture comment above). + AssertElementwiseComparisonOperators( + left, left, leftVals, leftVals, + (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "int4 tied vector-vector"); } // ---- bool2/3/4 (no ordering operators) ---------------------------------------------------