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)
| 99 | // fact store in the process. |
| 100 | // Analysis considers only predicates that are found in the store. |
| 101 | func 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 | |
| 124 | func TestSingleDeltaRule(t *testing.T) { |
| 125 | rule := clause("path(X,Z,U) :- edge(X,Y), path(Y,W,Z) |> let U = fn:plus(Z, 1).") |
no test coverage detected