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/ddr-facing-via-continuation.test.ts
import {expect,test} from 'bun:test'
import {explicitFacingViaContinuation} from '../scripts/ddr-facing-via-continuation'
const w=(x:number,y:number,layer='top')=>({route_type:'wire',x,y,layer,width:.12})
const via={route_type:'via',x:0,y:0,from_layer:'top',to_layer:'inner2',via_diameter:.4572,via_hole_diameter:.254}
const before={pcb_trace_id:'saved',source_trace_id:'net',route:[w(-.4,-.4),w(0,0),via,w(0,0,'inner2'),w(-1,0,'inner2')]}
const raw={route:[w(-.4,-.4),w(0,0),{...via,to_layer:'inner4'},{...via,to_layer:'inner4',layer:'inner4',width:.12},w(0,.2,'inner4'),w(.2,.4,'inner4')]}
test('explicit via vertex preserves original launch, physical barrel and solver tail',()=>{
const r=explicitFacingViaContinuation(before,raw,'inner4')
expect(r.omittedCenterDistanceMm).toBe(.2)
expect(r.after.route.slice(0,2)).toEqual(before.route.slice(0,2))
expect(r.after.route[2]).toEqual({...via,to_layer:'inner4'})
expect(r.after.route[3]).toEqual(w(0,0,'inner4'))
expect(r.after.route.slice(4)).toEqual(raw.route.slice(4))
expect(r.after.source_trace_id).toBe('net')
})
test('reject altered launch, missing layer contract and hidden non-octilinear first segment',()=>{
const moved=structuredClone(raw);moved.route[0]!.x=-.5
expect(()=>explicitFacingViaContinuation(before,moved,'inner4')).toThrow()
expect(()=>explicitFacingViaContinuation(before,raw,'inner6')).toThrow()
const skewed=structuredClone(raw);skewed.route[4]!.x=.01
expect(()=>explicitFacingViaContinuation(before,skewed,'inner4')).toThrow()
})