From fc19d899eb5ef8e27713227dfab44aaf8a3be300 Mon Sep 17 00:00:00 2001 From: mo <131036780+mbolling@users.noreply.github.com> Date: Sat, 28 Nov 2026 18:18:00 +0000 Subject: [PATCH] Test: a layer-0 attribute of a nested reference follows the outer reference's layer Co-Authored-By: Claude Fable 5.2 --- crates/render/src/tests.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/crates/render/src/tests.rs b/crates/render/src/tests.rs index a5d0cc35e..a7ef2a780 100644 --- a/crates/render/src/tests.rs +++ b/crates/render/src/tests.rs @@ -1046,6 +1046,36 @@ fn attribute_set_on_layer_zero_does_not_take_the_reference_layer() { assert!(own.iter().all(|t| *t < line), "{own:?}"); } +#[test] +fn attribute_on_layer_zero_of_a_nested_reference_follows_the_outer_reference() { + // A reference on the opaque layer A, with an attribute set on layer 0, sits inside block + // Outer beside a layer-0 line; Outer is placed on a 40 % layer. In Outer the attribute is + // layer-0 content like that line, so both take the outer reference's layer: not layer 0 + // itself, and not layer A, which only the inner block's own line takes. + let mut d = Drawing::new_imperial(); + d.layers.push(cadcraft_doc::Layer { name: "A".into(), ..Default::default() }); + let mut inner = cadcraft_doc::Block::new("B"); + let (c, k) = line_common(Common::default()); + inner.entities.push(block_entity(1, c, k)); + inner.entities.push(block_entity(2, Common::default(), EntityKind::AttDef(attrib("TAG")))); + d.blocks.insert("B".into(), std::sync::Arc::new(inner)); + let EntityKind::Insert(mut ins) = insert_of("B") else { panic!("an insert") }; + let props = cadcraft_doc::AttribProps { layer: Some("0".into()), ..Default::default() }; + ins.attribs.push(cadcraft_doc::Attrib { props, ..attrib("TAG") }); + let mut outer = cadcraft_doc::Block::new("Outer"); + let (c, k) = line_common(Common::default()); + outer.entities.push(block_entity(3, c, k)); + outer.entities.push(block_entity(4, Common { layer: "A".into(), ..Default::default() }, EntityKind::Insert(ins))); + d.blocks.insert("Outer".into(), std::sync::Arc::new(outer)); + d.add(&Space::Model, Common { layer: "Glass".into(), ..Default::default() }, insert_of("Outer")).unwrap(); + d.layer_mut("Glass").unwrap().transparency = 40; + let l = build(&d, &Space::Model, &with_transparency()); + let [outer_line, inner_line, text @ ..] = l.prims.as_slice() else { panic!("two lines and the attribute") }; + assert!(!text.is_empty(), "the attribute is drawn"); + assert!(inner_line.transparency < outer_line.transparency, "the inner block's line is on layer A"); + assert!(text.iter().all(|p| p.transparency == outer_line.transparency), "the attribute follows the outer reference's layer"); +} + #[test] fn mtext_exact_spacing_ignores_taller_lines() { // #711: a doubled middle line pushes the next baseline down with At least, not with Exactly.