From 1e9ec06ae40393719acd0a015f693dc2b8960867 Mon Sep 17 00:00:00 2001 From: AnasSarkiz Date: Sun, 30 Aug 2026 22:00:12 +0200 Subject: [PATCH 1/2] test: cover noisy boundary coordinates in A01 --- .../boundary-coordinate-tolerance.test.ts | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 tests/repros/boundary-coordinate-tolerance/boundary-coordinate-tolerance.test.ts diff --git a/tests/repros/boundary-coordinate-tolerance/boundary-coordinate-tolerance.test.ts b/tests/repros/boundary-coordinate-tolerance/boundary-coordinate-tolerance.test.ts new file mode 100644 index 0000000..6ca51f9 --- /dev/null +++ b/tests/repros/boundary-coordinate-tolerance/boundary-coordinate-tolerance.test.ts @@ -0,0 +1,85 @@ +import { expect, test } from "bun:test" +import { defaultParams } from "../../../lib/default-params" +import { HighDensitySolverA01 } from "../../../lib/HighDensitySolverA01/HighDensitySolverA01" +import type { NodeWithPortPoints } from "../../../lib/types" +import { validateNoIntersections } from "../../fixtures/validateNoIntersections" + +const boundaryCoordinateNoiseMm = 2.1349678824833518e-7 + +const nodeWithPortPoints: NodeWithPortPoints = { + capacityMeshNodeId: "boundary-coordinate-tolerance-node", + center: { x: 5, y: 5 }, + width: 10, + height: 10, + availableZ: [0, 1], + portPoints: [ + { + connectionName: "transition", + x: 5, + y: 10 + boundaryCoordinateNoiseMm, + z: 0, + }, + { + connectionName: "transition", + x: 5, + y: -boundaryCoordinateNoiseMm, + z: 1, + }, + { + connectionName: "flat", + x: -boundaryCoordinateNoiseMm, + y: 5, + z: 0, + }, + { + connectionName: "flat", + x: 10 + boundaryCoordinateNoiseMm, + y: 5, + z: 0, + }, + ], +} + +function createBoundaryToleranceSolver(): HighDensitySolverA01 { + const solver = new HighDensitySolverA01({ + ...defaultParams, + nodeWithPortPoints, + }) + solver.solve() + return solver +} + +test("A01 deterministically routes noisy boundary coordinates without moving endpoints", () => { + const firstSolver = createBoundaryToleranceSolver() + const repeatedSolver = createBoundaryToleranceSolver() + const firstOutput = firstSolver.getOutput() + const flatRoute = firstOutput.find((route) => route.connectionName === "flat") + const transitionRoute = firstOutput.find( + (route) => route.connectionName === "transition", + ) + + expect(firstSolver.solved).toBe(true) + expect(firstSolver.failed).toBe(false) + expect(repeatedSolver.getOutput()).toEqual(firstOutput) + expect(flatRoute?.route.at(0)).toMatchObject({ + x: -boundaryCoordinateNoiseMm, + y: 5, + z: 0, + }) + expect(flatRoute?.route.at(-1)).toMatchObject({ + x: 10 + boundaryCoordinateNoiseMm, + y: 5, + z: 0, + }) + expect(transitionRoute?.route.at(0)).toMatchObject({ + x: 5, + y: 10 + boundaryCoordinateNoiseMm, + z: 0, + }) + expect(transitionRoute?.route.at(-1)).toMatchObject({ + x: 5, + y: -boundaryCoordinateNoiseMm, + z: 1, + }) + validateNoIntersections(firstOutput) +}) From d8efa9a77607ede71386b0b0a7845c82543a3a14 Mon Sep 17 00:00:00 2001 From: AnasSarkiz Date: Sun, 30 Aug 2026 22:36:05 +0200 Subject: [PATCH 2/2] test: snapshot noisy boundary routing --- .../boundary-coordinate-tolerance.snap.svg | 44 +++++++++++++++++++ .../boundary-coordinate-tolerance.test.ts | 5 ++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 tests/repros/boundary-coordinate-tolerance/__snapshots__/boundary-coordinate-tolerance.snap.svg diff --git a/tests/repros/boundary-coordinate-tolerance/__snapshots__/boundary-coordinate-tolerance.snap.svg b/tests/repros/boundary-coordinate-tolerance/__snapshots__/boundary-coordinate-tolerance.snap.svg new file mode 100644 index 0000000..395b4b3 --- /dev/null +++ b/tests/repros/boundary-coordinate-tolerance/__snapshots__/boundary-coordinate-tolerance.snap.svg @@ -0,0 +1,44 @@ + \ No newline at end of file diff --git a/tests/repros/boundary-coordinate-tolerance/boundary-coordinate-tolerance.test.ts b/tests/repros/boundary-coordinate-tolerance/boundary-coordinate-tolerance.test.ts index 6ca51f9..6ba3c5e 100644 --- a/tests/repros/boundary-coordinate-tolerance/boundary-coordinate-tolerance.test.ts +++ b/tests/repros/boundary-coordinate-tolerance/boundary-coordinate-tolerance.test.ts @@ -1,4 +1,6 @@ import { expect, test } from "bun:test" +import "bun-match-svg" +import "graphics-debug/matcher" import { defaultParams } from "../../../lib/default-params" import { HighDensitySolverA01 } from "../../../lib/HighDensitySolverA01/HighDensitySolverA01" import type { NodeWithPortPoints } from "../../../lib/types" @@ -49,7 +51,7 @@ function createBoundaryToleranceSolver(): HighDensitySolverA01 { return solver } -test("A01 deterministically routes noisy boundary coordinates without moving endpoints", () => { +test("A01 deterministically routes noisy boundary coordinates without moving endpoints", async () => { const firstSolver = createBoundaryToleranceSolver() const repeatedSolver = createBoundaryToleranceSolver() const firstOutput = firstSolver.getOutput() @@ -82,4 +84,5 @@ test("A01 deterministically routes noisy boundary coordinates without moving end z: 1, }) validateNoIntersections(firstOutput) + await expect(firstSolver.visualize()).toMatchGraphicsSvg(import.meta.path) })