-
Notifications
You must be signed in to change notification settings - Fork 41
fix: same name of the components should add an error to the circuit json #724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { getTestFixture } from "tests/fixtures/get-test-fixture" | ||
import { test } from "bun:test" | ||
import { expect } from "bun:test" | ||
test("repro-12: same name of components in subcircuit", async () => { | ||
const { circuit } = getTestFixture() | ||
|
||
circuit.add( | ||
<group subcircuit> | ||
<resistor resistance="1k" footprint="0402" name="R1" schX={3} pcbX={3} /> | ||
<resistor | ||
resistance="1k" | ||
footprint="0402" | ||
name="R1" | ||
schX={-3} | ||
pcbX={-3} | ||
/> | ||
<trace from=".R1 > .pin1" to=".R1 > .pin1" /> | ||
</group>, | ||
) | ||
|
||
await circuit.renderUntilSettled() | ||
|
||
const pcb_trace_errors = circuit.db.pcb_trace_error.list() | ||
expect(pcb_trace_errors).toHaveLength(1) | ||
}) | ||
|
||
test("repro-12: same name of components in board", async () => { | ||
const { circuit } = getTestFixture() | ||
|
||
circuit.add( | ||
<board width="10mm" height="10mm"> | ||
<resistor resistance="1k" footprint="0402" name="R1" schX={3} pcbX={3} /> | ||
<resistor | ||
resistance="1k" | ||
footprint="0402" | ||
name="R1" | ||
schX={-3} | ||
pcbX={-3} | ||
/> | ||
<trace from=".R1 > .pin1" to=".R1 > .pin1" /> | ||
</board>, | ||
) | ||
|
||
await circuit.renderUntilSettled() | ||
|
||
const pcb_trace_errors = circuit.db.pcb_trace_error.list() | ||
expect(pcb_trace_errors).toHaveLength(1) | ||
}) | ||
|
||
test("repro-12: same name of components in different subcircuits should not be an error", async () => { | ||
const { circuit } = getTestFixture() | ||
|
||
circuit.add( | ||
<group> | ||
<group subcircuit> | ||
<resistor | ||
resistance="1k" | ||
footprint="0402" | ||
name="R1" | ||
schX={3} | ||
pcbX={3} | ||
/> | ||
<resistor | ||
resistance="1k" | ||
footprint="0402" | ||
name="R2" | ||
schX={-3} | ||
pcbX={-3} | ||
/> | ||
<trace from=".R1 > .pin1" to=".R1 > .pin1" /> | ||
</group> | ||
<subcircuit> | ||
<resistor | ||
resistance="1k" | ||
footprint="0402" | ||
name="R1" | ||
schX={3} | ||
pcbX={3} | ||
/> | ||
<resistor | ||
resistance="1k" | ||
footprint="0402" | ||
name="R2" | ||
schX={-3} | ||
pcbX={-3} | ||
/> | ||
</subcircuit> | ||
</group>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a valid circuit that shouldnt error. Names must be unique within a subcircuit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't I am checking for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Woops sorry ty!! |
||
) | ||
|
||
await circuit.renderUntilSettled() | ||
|
||
// No errors because the components are in different subcircuits | ||
const pcb_trace_errors = circuit.db.pcb_trace_error.list() | ||
expect(pcb_trace_errors).toHaveLength(0) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Subcircuit component name checking is good 👍 this one doesnt need to go on the board
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, we don't need to check it here in Board. But we will have to import from the Group class for this behaviour to be accepted, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can call the super method inside the board so that it runs the DRC checks that run for any subcircuit. You can alternatively create an internal underscore function that does what the subcircuit does. For example _checkForConflictingNames()