-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathnecessary-cramped-port-point-solver-no-duplicate-explosion.test.ts
More file actions
40 lines (31 loc) · 1.54 KB
/
necessary-cramped-port-point-solver-no-duplicate-explosion.test.ts
File metadata and controls
40 lines (31 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { expect, test } from "bun:test"
import missingPortPointsFixture from "../../fixtures/bug-reports/missing-port-points-001/missing-port-points-001.json"
import { AutoroutingPipelineSolver3_HgPortPointPathing } from "../../lib/autorouter-pipelines/AutoroutingPipeline2_PortPointPathing/AutoroutingPipelineSolver3_HgPortPointPathing"
import { SingleTargetNecessaryCrampedPortPointSolver } from "../../lib/solvers/NecessaryCrampedPortPointSolver/SingleTargetNecessaryCrampedPortPointSolver"
import type { SimpleRouteJson } from "../../lib/types"
test("necessary cramped port point solver does not explode duplicate candidates", () => {
const srj = missingPortPointsFixture as SimpleRouteJson
const singleTargetStats: Array<{
candidateCount: number
}> = []
const originalStep =
SingleTargetNecessaryCrampedPortPointSolver.prototype._step
SingleTargetNecessaryCrampedPortPointSolver.prototype._step =
function patchedStep() {
originalStep.call(this)
if (!this.solved) return
singleTargetStats.push({
// methods are private so need to convert to any
candidateCount: (this as any).resultExploredPortPoints.length,
})
}
const solver = new AutoroutingPipelineSolver3_HgPortPointPathing(srj)
solver.solve()
expect(solver.solved).toBe(true)
expect(solver.failed).toBe(false)
const maxCandidateCount = Math.max(
...singleTargetStats.map((stat) => stat.candidateCount),
)
expect(maxCandidateCount).toBeLessThan(500)
SingleTargetNecessaryCrampedPortPointSolver.prototype._step = originalStep
})