Schedule sibling inheritance by dependency readiness

This commit is contained in:
2026-10-19 17:25:27 +00:00
parent a56d4691ff
commit 6e40c166d6
5 changed files with 50 additions and 296 deletions

View File

@@ -110,6 +110,41 @@ beta:
}
}
func TestInheritanceExpansionInterleavesUnequalBranches(t *testing.T) {
root := parseCompositionDocument(t, "branches", `a-grandchild:
extends: z-child
own: grandchild
b-base:
base: b
c-base:
base: c
d-child:
extends: c-base
own: d
z-child:
extends: b-base
own: z
`)
result, diagnostics := expandInheritanceTree(root, defaultProjectionLimits())
if len(diagnostics) != 0 {
t.Fatalf("expand diagnostics = %#v", diagnostics)
}
got := make([]string, len(result.transfers))
for i, transfer := range result.transfers {
got[i] = transfer.from.String() + " -> " + transfer.to.String()
}
want := []string{"/c-base -> /d-child", "/b-base -> /z-child", "/z-child -> /a-grandchild"}
if !reflect.DeepEqual(got, want) {
t.Fatalf("transfer order = %v, want %v", got, want)
}
if value, found := documentAtPath(result.root, Path{}.Key("a-grandchild").Key("base")); !found || value.Text != "b" {
t.Fatalf("grandchild inherited value = %#v, found %t", value, found)
}
if value, found := documentAtPath(result.root, Path{}.Key("d-child").Key("base")); !found || value.Text != "c" {
t.Fatalf("independent branch inherited value = %#v, found %t", value, found)
}
}
func TestInheritanceGraphValidatesRelationshipKinds(t *testing.T) {
tests := []struct {
name string