|
1 | 1 | import { DsnPin } from "lib/sexpr" |
| 2 | +import { SxClass } from "lib/sexpr/base-classes/SxClass" |
2 | 3 | import { test, expect } from "bun:test" |
3 | 4 |
|
4 | 5 | test("DsnPin without quotes on padstack ID", () => { |
@@ -44,3 +45,54 @@ test("DsnPin with rotation", () => { |
44 | 45 | "(pin RoundRect[T]Pad_540x640_135.514_um_0.000000_0_source_component_0 1 -500 0 90)", |
45 | 46 | ) |
46 | 47 | }) |
| 48 | + |
| 49 | +test("DsnPin parses numeric pin_id correctly from DSN format", () => { |
| 50 | + // Format: (pin <padstack_id> <pin_id> <x> <y>) |
| 51 | + // Where pin_id is numeric (12), x is -2525, y is -6350 |
| 52 | + const pin = DsnPin.fromSexprPrimitives([ |
| 53 | + "Rect[T]Pad_3150.000000x1000.000000_um", |
| 54 | + 12, |
| 55 | + -2525, |
| 56 | + -6350, |
| 57 | + ]) |
| 58 | + |
| 59 | + expect(pin.padstackId).toBe("Rect[T]Pad_3150.000000x1000.000000_um") |
| 60 | + expect(pin.pinId).toBe("12") |
| 61 | + expect(pin.x).toBe(-2525) |
| 62 | + expect(pin.y).toBe(-6350) |
| 63 | + expect(pin.rotation).toBeUndefined() |
| 64 | +}) |
| 65 | + |
| 66 | +test("DsnPin parses inline (rotate ...) expression correctly", () => { |
| 67 | + // Format: (pin <padstack_id> (rotate <angle>) <pin_id> <x> <y>) |
| 68 | + const pin = DsnPin.fromSexprPrimitives([ |
| 69 | + "Round[T]Pad_1730.000000_um", |
| 70 | + ["rotate", 90], |
| 71 | + 1, |
| 72 | + 0, |
| 73 | + 0, |
| 74 | + ]) |
| 75 | + |
| 76 | + expect(pin.padstackId).toBe("Round[T]Pad_1730.000000_um") |
| 77 | + expect(pin.pinId).toBe("1") |
| 78 | + expect(pin.x).toBe(0) |
| 79 | + expect(pin.y).toBe(0) |
| 80 | + expect(pin.rotation).toBe(90) |
| 81 | +}) |
| 82 | + |
| 83 | +test("DsnPin parses rotation at end of expression", () => { |
| 84 | + // Format: (pin <padstack_id> <pin_id> <x> <y> <rotation>) |
| 85 | + const pin = DsnPin.fromSexprPrimitives([ |
| 86 | + "Rect[T]Pad_1000x1000_um", |
| 87 | + "A1", |
| 88 | + 100, |
| 89 | + 200, |
| 90 | + 45, |
| 91 | + ]) |
| 92 | + |
| 93 | + expect(pin.padstackId).toBe("Rect[T]Pad_1000x1000_um") |
| 94 | + expect(pin.pinId).toBe("A1") |
| 95 | + expect(pin.x).toBe(100) |
| 96 | + expect(pin.y).toBe(200) |
| 97 | + expect(pin.rotation).toBe(45) |
| 98 | +}) |
0 commit comments