diff --git a/slhx-derive/tests/compile_fail.rs b/slhx-derive/tests/compile_fail.rs index d37dd85..473ed58 100644 --- a/slhx-derive/tests/compile_fail.rs +++ b/slhx-derive/tests/compile_fail.rs @@ -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] fn generated_resource_references_fail_when_name_is_absent() { // req: style/002 req: codegen/001 req: test/003