Files
diodeinc__pcb/crates/pcb-star/tests/assert.rs
Lenny Khazan e852477546 Initial release (#5)
* 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
2025-07-01 04:06:08 -04:00

59 lines
1.2 KiB
Rust
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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");
}