test(derive): cover surface inline requirement

Add compile-fail coverage for #[slhx::surface] on non-inline modules so the generated surface boundary stays explicit.

req: codegen/001

req: test/003
This commit is contained in:
slhx agent
2026-05-25 21:30:18 +02:00
parent 87a19fd923
commit 59b0c8ccc4
+38
View File
@@ -212,6 +212,44 @@ pub mod ui {}
); );
} }
#[test]
fn surface_macro_requires_inline_module() {
// req: codegen/001 req: test/003
let fixture = Fixture::new("slhx-derive-surface-inline-fail");
fixture.write(
"Cargo.toml",
&format!(
r#"[package]
name = "slhx-derive-surface-inline-fail"
version = "0.0.0"
edition = "2021"
[lib]
path = "src/lib.rs"
[dependencies]
slhx = {{ path = {:?} }}
"#,
repo_path("slhx")
),
);
fixture.write(
"src/lib.rs",
r#"#[slhx::surface]
pub mod ui;
"#,
);
let output = check_fixture(&fixture);
assert!(!output.status.success(), "fixture unexpectedly compiled");
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("#[slhx::surface] must be used on an inline module"),
"missing inline-module diagnostic in stderr:\n{stderr}"
);
}
#[test] #[test]
fn generated_resource_references_fail_when_name_is_absent() { fn generated_resource_references_fail_when_name_is_absent() {
// req: style/002 req: codegen/001 req: test/003 // req: style/002 req: codegen/001 req: test/003