MCPcopy Create free account
hub / github.com/cel-expr/cel-go / propagateVisitedness

Function propagateVisitedness

tools/celtest/test_runner.go:1072–1080  ·  view source on GitHub ↗

propagateVisitedness implements two rules for extending the coverage report: - If a node is visited, all its ancestors are visited. - If a node is visited, and it has only one child, then the child is visited.

(root *cel.Ast, coverageStats map[int64]set, state interpreter.EvalState)

Source from the content-addressed store, hash-verified

1070// - If a node is visited, all its ancestors are visited.
1071// - If a node is visited, and it has only one child, then the child is visited.
1072func propagateVisitedness(root *cel.Ast, coverageStats map[int64]set, state interpreter.EvalState) {
1073 if root == nil || coverageStats == nil {
1074 return
1075 }
1076 // Propagate visitedness upwards for ancestors.
1077 ast.PostOrderVisit(root.NativeRep().Expr(), parentVisitor{coverageStats: coverageStats, evalState: state})
1078 // Propagate visitedness downwards for single-child nodes.
1079 ast.PostOrderVisit(root.NativeRep().Expr(), childrenVisitor{coverageStats: coverageStats, evalState: state})
1080}
1081
1082// childrenVisitor is a visitor that populates the coverageStats for the child nodes of a given expression.
1083type childrenVisitor struct {

Callers 1

collectCoverageStatsFunction · 0.85

Calls 3

PostOrderVisitFunction · 0.92
NativeRepMethod · 0.80
ExprMethod · 0.65

Tested by

no test coverage detected