0hmX/am3352
This code suite comprises TypeScript scripts that analyze, verify, and assemble complex DDR memory interface hardware, focusing on physical routing, via and pad placement, electrical clearance, and physical constraints, often involving precise geometric calculations and consistent provenance tracking.
- Version
- 1.0.5
- License
- unset
- Stars
- 0
tests/route-angles.test.ts
import { expect, test } from 'bun:test'
import { auditRouteAngles } from '../scripts/check-route-angles'
const wires=(points:number[][])=>[{connection:'fixture',route:points.map(([x,y])=>({route_type:'wire',x,y,layer:'top'}))}]
test('45-degree bends pass; orthogonal corners and diagonal triangle peaks fail',()=>{
expect(auditRouteAngles(wires([[0,0],[1,0],[2,1],[2,2]])).valid).toBe(true)
expect(auditRouteAngles(wires([[0,0],[1,0],[1,1]])).valid).toBe(false)
expect(auditRouteAngles(wires([[0,0],[1,1],[0,2]])).valid).toBe(false)
})
test('duplicate vertices cannot hide a sharp corner, and backtracking fails',()=>{
expect(auditRouteAngles(wires([[0,0],[1,0],[1,0],[1,1]])).valid).toBe(false)
expect(auditRouteAngles(wires([[0,0],[1,0],[0,0]])).valid).toBe(false)
})
test('heading audit rejects straight off-angle stubs even when bend-only diagnostics pass',()=>{
const stub=wires([[0,0],[.2,.3]])
expect(auditRouteAngles(stub,false).valid).toBe(true)
expect(auditRouteAngles(stub).valid).toBe(false)
})
test('malformed coordinates and unknown primitives cannot bypass the angle gate',()=>{
for(const n of[NaN,Infinity,-Infinity])expect(auditRouteAngles(wires([[0,0],[n,1]])).valid).toBe(false)
const hidden=wires([[0,0],[1,0],[1,1]])
hidden[0]!.route.splice(2,0,{route_type:'gap',x:1,y:0,layer:'top'})
expect(auditRouteAngles(hidden).valid).toBe(false)
const missing=wires([[0,0],[1,1]]);missing[0]!.route[1]!.layer=''
expect(auditRouteAngles(missing).valid).toBe(false)
})