diff --git a/core/dr-pipeline/src/lib.rs b/core/dr-pipeline/src/lib.rs index a763ef9..a651c3a 100644 --- a/core/dr-pipeline/src/lib.rs +++ b/core/dr-pipeline/src/lib.rs @@ -107,12 +107,38 @@ mod tests { let g = fully_active(); assert!(!g.is_neutral()); let shader = g.compose(); - // Counted against the chain rather than a literal, so adding an - // operation does not require editing this test. + + // The chain has two kinds of operation in it and they arrive in + // different places: a point operation is a block in the fused shader, + // while a neighbourhood operation is a pass of the detail chain and + // contributes no fused block at all — it reads pixels it is not + // writing, and a fused fragment is handed a colour with no coordinate. + // + // So the assertion is that each operation reaches exactly one of the + // two, checked against the chain rather than a literal, and phrased so + // that adding either kind extends it without an edit here. + let scale = g.render_scale((4000, 3000), (4000, 3000)); + let detail = g.compose_detail(scale); + let mut fused_blocks = 0; + for desc in g.descriptors() { + let id = desc.id.0; + let point = shader.source.contains(&format!("---- {id} ----")); + let neighbourhood = detail + .passes + .iter() + .any(|p| p.label.starts_with(&format!("{id}/"))); + assert!( + point ^ neighbourhood, + "{id} reaches {} of the two stages; an active operation \ + belongs to exactly one", + if point { "both" } else { "neither" } + ); + fused_blocks += usize::from(point); + } assert_eq!( shader.source.matches("---- ").count(), - g.descriptors().len(), - "every operation in the chain should appear" + fused_blocks, + "the fused shader carries a block nothing in the chain asked for" ); }