resolve tests: room for deep Clone and Debug; boundary pinned once

This commit is contained in:
Meta Vens 2026-11-28 00:59:58 +01:00
commit b2d8702c76

View file

@ -15,6 +15,14 @@ use thing_testkit::store;
const PUB: &str = "pub.t";
/// Room for a test that clones, prints or compares a deep Node: the contract's derived Clone, Debug
/// and PartialEq cost about 12 KiB of debug stack per level, so a 256-level tree overflows a default
/// thread outside resolve (reported as thing2:cut_report:cut-bind-pin.h1). The tests that run resolve
/// itself on a default thread do not use this.
fn with_room(work: impl FnOnce()) {
stacker::grow(64 * 1024 * 1024, work);
}
fn surface(root: Node, commands: &[&str]) -> SurfaceDocument {
SurfaceDocument {
provider_id: ProviderId::new("provider.t"),
@ -184,6 +192,10 @@ fn fixture_resolution(fixture: Fixture, label: &str) -> Resolution {
#[test]
fn f09_expands() {
with_room(f09_expands_body);
}
fn f09_expands_body() {
let set = Fixture::F09CompositionStack.load();
let state = MemState::from_fixture(Fixture::F09CompositionStack);
let resolution = run(&set.surfaces[0], &state);
@ -354,6 +366,10 @@ fn a_slot_placed_twice_per_level_is_counted_when_it_is_spliced() {
#[test]
fn a_tree_deeper_than_the_limit_is_refused() {
with_room(a_tree_deeper_than_the_limit_is_refused_body);
}
fn a_tree_deeper_than_the_limit_is_refused_body() {
let mut deep = boxed("leaf", vec![]);
for level in 0..257 {
deep = boxed(&format!("level-{level}"), vec![deep]);
@ -938,16 +954,21 @@ 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.
/// One level past the stack bound 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_is_inclusive() {
// 1,024 levels is the deepest the expander recurses into; the depth rule refuses it later.
let at_bound = resolve_nested(1024, Through::BoxChildren);
refused_for_limit(&at_bound);
assert!(!too_deep_to_resolve(&at_bound), "{:?}", at_bound.diagnostics);
}
#[test]
fn the_stack_bound_counts_box_children() {
stack_bound_counts(Through::BoxChildren);