Reuse frozen inspection mapping lookups

This commit is contained in:
2026-10-09 03:54:14 +00:00
parent 344f4f73d7
commit d32c94eca3
9 changed files with 85 additions and 14 deletions

View File

@@ -102,7 +102,11 @@ func TestDocumentLookupMatchesPathScan(t *testing.T) {
{Key: "01", Value: &document.Node{Kind: document.String, Text: "leading zero key"}},
{Key: "items", Value: sequence},
}}
lookup := buildDocumentLookup(root)
applicationRoot := &document.Node{Kind: document.Mapping, Mapping: []document.Entry{
{Key: "shared", Value: sequence},
{Key: "application", Value: &document.Node{Kind: document.Mapping, Mapping: []document.Entry{{Key: "value", Value: &document.Node{Kind: document.String, Text: "application"}}}}},
}}
lookup := buildDocumentLookup(root, applicationRoot)
paths := []Path{
Path{},
Keys("0"),
@@ -123,6 +127,13 @@ func TestDocumentLookupMatchesPathScan(t *testing.T) {
t.Errorf("indexed lookup %s = (%p, %v), want (%p, %v)", path.String(), gotNode, gotFound, wantNode, wantFound)
}
}
for _, path := range []Path{Path{}, Keys("shared"), Keys("shared").Index(1).Key("name"), Keys("application", "value")} {
wantNode, wantFound := documentAtPath(applicationRoot, path)
gotNode, gotFound := documentAtPathWithLookup(applicationRoot, path, lookup)
if gotNode != wantNode || gotFound != wantFound {
t.Errorf("indexed application lookup %s = (%p, %v), want (%p, %v)", path.String(), gotNode, gotFound, wantNode, wantFound)
}
}
}
func TestApplyResolutionMetadataPreservesOverlappingDeltaOrder(t *testing.T) {