Skip to content

Commit 0b2a9d5

Browse files
committed
test(perturbation-sim): lock basin_lambda2 key-count precondition
CodeRabbit nitpick on #512: the new keys.len() == grid.n assert had no regression test. Add a #[should_panic] test asserting a short key vector (keys.len() == n-1) trips the precondition with the expected message, so a future refactor can't silently drop the guard. https://claude.ai/code/session_016b33swuXE23hKtqxsHu9p1
1 parent b2732db commit 0b2a9d5

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

crates/perturbation-sim/src/hhtl.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,15 @@ mod tests {
179179
assert!(!l2.is_empty(), "at least one keyed basin");
180180
assert_eq!(k.len(), g.n);
181181
}
182+
183+
#[test]
184+
#[should_panic(expected = "exactly one HHTL key per grid node")]
185+
fn basin_lambda2_rejects_key_count_mismatch() {
186+
// Locks the one-key-per-node precondition: a short key vector must panic
187+
// rather than silently group the wrong nodes.
188+
let g = grid_2x2_blocks();
189+
let mut k = hhtl_keys(&g);
190+
k.pop(); // keys.len() == g.n - 1
191+
let _ = basin_lambda2(&g, &k);
192+
}
182193
}

0 commit comments

Comments
 (0)