From 8571dd299ab300b1de46eb3a787f3709098d1d01 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 28 Nov 2026 00:59:20 +0100 Subject: [PATCH] resolve tests: one stack-bound test per way a node nests --- crates/thing-core/tests/resolve.rs | 41 +++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/crates/thing-core/tests/resolve.rs b/crates/thing-core/tests/resolve.rs index 4a5fc4f..5b1fe41 100644 --- a/crates/thing-core/tests/resolve.rs +++ b/crates/thing-core/tests/resolve.rs @@ -938,16 +938,39 @@ fn a_chain_past_the_depth_rule_and_within_the_stack_bound_resolves_then_is_refus assert!(!too_deep_to_resolve(&resolution), "{:?}", resolution.diagnostics); } +/// 1,024 levels is the deepest the expander recurses into (the depth rule refuses such a tree +/// later); one more is `TooDeepToResolve`, whichever way the levels nest. +fn stack_bound_counts(through: Through) { + let at_bound = resolve_nested(1024, through); + assert!(!too_deep_to_resolve(&at_bound), "{through:?}: {:?}", at_bound.diagnostics); + let past = resolve_nested(1025, through); + assert!(past.tree.is_none(), "{through:?}"); + assert!(too_deep_to_resolve(&past), "{through:?}: {:?}", past.diagnostics); +} + #[test] -fn the_stack_bound_counts_every_way_a_node_nests_and_refuses_at_the_next_level() { - for through in [Through::BoxChildren, Through::RepeatTemplate, Through::ButtonContent, Through::OverlayChildren, Through::SlotArgument] { - // 1,024 levels is the deepest the expander recurses into; the depth rule refuses it later. - let at_bound = resolve_nested(1024, through); - assert!(!too_deep_to_resolve(&at_bound), "{through:?}: {:?}", at_bound.diagnostics); - let past = resolve_nested(1025, through); - assert!(past.tree.is_none(), "{through:?}"); - assert!(too_deep_to_resolve(&past), "{through:?}: {:?}", past.diagnostics); - } +fn the_stack_bound_counts_box_children() { + stack_bound_counts(Through::BoxChildren); +} + +#[test] +fn the_stack_bound_counts_a_repeat_template() { + stack_bound_counts(Through::RepeatTemplate); +} + +#[test] +fn the_stack_bound_counts_button_content() { + stack_bound_counts(Through::ButtonContent); +} + +#[test] +fn the_stack_bound_counts_overlay_children() { + stack_bound_counts(Through::OverlayChildren); +} + +#[test] +fn the_stack_bound_counts_a_slot_argument() { + stack_bound_counts(Through::SlotArgument); } #[test]