MCPcopy
hub / github.com/google/mangle / analyzeAndEvalProgramWithDecls

Function analyzeAndEvalProgramWithDecls

engine/seminaivebottomup_test.go:101–122  ·  view source on GitHub ↗

analyzeAndEvalProgram analyzes and evaluates a given program on the given facts, modifying the fact store in the process. Analysis considers only predicates that are found in the store.

(t *testing.T, clauses []ast.Clause, decls []ast.Decl, store factstore.SimpleInMemoryStore, options ...EvalOption)

Source from the content-addressed store, hash-verified

99// fact store in the process.
100// Analysis considers only predicates that are found in the store.
101func analyzeAndEvalProgramWithDecls(t *testing.T, clauses []ast.Clause, decls []ast.Decl, store factstore.SimpleInMemoryStore, options ...EvalOption) error {
102 t.Helper()
103 programInfo, err := analysis.AnalyzeOneUnit(
104 parse.SourceUnit{Clauses: clauses, Decls: decls}, asMap(store.ListPredicates()))
105 if err != nil {
106 return fmt.Errorf("analysis: %w", err)
107 }
108 for _, f := range programInfo.InitialFacts {
109 store.Add(f)
110 }
111
112 strata, predToStratum, err := analysis.Stratify(analysis.Program{
113 EdbPredicates: programInfo.EdbPredicates,
114 IdbPredicates: programInfo.IdbPredicates,
115 Rules: programInfo.Rules,
116 })
117 if err != nil {
118 return fmt.Errorf("stratification: %w", err)
119 }
120 _, err = EvalStratifiedProgramWithStats(programInfo, strata, predToStratum, store, options...)
121 return err
122}
123
124func TestSingleDeltaRule(t *testing.T) {
125 rule := clause("path(X,Z,U) :- edge(X,Y), path(Y,W,Z) |> let U = fn:plus(Z, 1).")

Callers 3

TestShortestPathsFunction · 0.85
analyzeAndEvalProgramFunction · 0.85
TestTopDownFunction · 0.85

Calls 6

AnalyzeOneUnitFunction · 0.92
StratifyFunction · 0.92
asMapFunction · 0.85
ListPredicatesMethod · 0.65
AddMethod · 0.65

Tested by

no test coverage detected