Skip to main content
Zener tests check connectivity, component properties, and circuit topology. TestBench instantiates a module for each input case, then runs check functions against the evaluated module.

Write a test bench

In a PCB workspace, create series.zen with two resistors in series:
Create test_series.zen beside it:
Run it with pcb test test_series.zen. Each check receives the evaluated module and its case’s input dictionary. check(condition, message), error(message), and unhandled evaluation errors fail the test with a source location. test_cases must be a nonempty map of case names to module input dictionaries. Supply all required io() and config() inputs; modules without required inputs can use an empty dictionary for a case.

Inspect the evaluated module

Call nets() and components() before accessing their dictionaries; the module itself does not support []. Component values expose name, type, pins, properties, sourcing fields, and component-specific properties such as resistance.

Search and match paths

graph.paths(start=..., end=..., max_depth=...) finds simple paths between public io() net names or (component_path, pin) tuples. Tuple paths use the graph’s full component paths, as returned in a path’s ports. max_depth bounds the path’s port count, not its component count; omitting it leaves the search unbounded. Set it explicitly for large circuits. Each path exposes ports, components, and nets. To test individual components, use a check function that succeeds by returning without an error:
For ordered topology checks, path.matches() calls each matcher with the path and current component index. A matcher returns the number of components it consumed; the sequence must consume the entire path. The resistor() factory above is a project-defined helper, not a prelude symbol. When searching among candidate paths, use suppress_errors=True to return False for a sequence mismatch instead of failing the test: