mirror of
https://github.com/diodeinc/pcb.git
synced 2026-09-14 20:17:19 +08:00
e852477546
* Initial release * cargo-dist * build and test CI * update ubuntu workflow * fmt * ubuntu: install deps * clippy: 0.1.88 fixes * format * install clippy * Update README.md * Don't run cargo-dist on PRs
59 lines
1.2 KiB
Rust
59 lines
1.2 KiB
Rust
mod common;
|
||
use common::TestProject;
|
||
|
||
/// Error case – evaluating `error()` should propagate the message.
|
||
#[test]
|
||
fn snapshot_error_function_should_error() {
|
||
let env = TestProject::new();
|
||
|
||
env.add_files_from_blob(
|
||
r#"
|
||
# --- test.star
|
||
error("boom")
|
||
"#,
|
||
);
|
||
|
||
star_snapshot!(env, "test.star");
|
||
}
|
||
|
||
/// `check()` with a true condition should pass and produce a schematic/netlist.
|
||
#[test]
|
||
fn snapshot_check_true_should_pass() {
|
||
let env = TestProject::new();
|
||
|
||
env.add_files_from_blob(
|
||
r#"
|
||
# --- test.star
|
||
# check should not raise when condition is true
|
||
check(True, "all good")
|
||
|
||
# Dummy component so schematic isn't empty
|
||
Component(
|
||
name = "comp0",
|
||
footprint = "TEST:0402",
|
||
pin_defs = {"P": "1"},
|
||
pins = {"P": Net("")},
|
||
)
|
||
"#,
|
||
);
|
||
|
||
// Should evaluate successfully and produce a netlist.
|
||
star_snapshot!(env, "test.star");
|
||
}
|
||
|
||
/// `check()` with a false condition should raise and surface the message.
|
||
#[test]
|
||
fn snapshot_check_false_should_error() {
|
||
let env = TestProject::new();
|
||
|
||
env.add_files_from_blob(
|
||
r#"
|
||
# --- test.star
|
||
# check should raise when condition is false
|
||
check(False, "failing condition")
|
||
"#,
|
||
);
|
||
|
||
star_snapshot!(env, "test.star");
|
||
}
|