(t *testing.T)
| 327 | } |
| 328 | |
| 329 | func TestSimpleEvalDefer(t *testing.T) { |
| 330 | store := factstore.NewSimpleInMemoryStore() |
| 331 | store.Add(atom("node(/a)")) |
| 332 | store.Add(atom("node(/b)")) |
| 333 | store.Add(atom("node(/c)")) |
| 334 | store.Add(atom("edge(/a,/b)")) |
| 335 | store.Add(atom("edge(/b,/c)")) |
| 336 | store.Add(atom("label(/a, 100)")) |
| 337 | |
| 338 | if err := analyzeAndEvalProgram(t, program, store, func(opt *EvalOptions) { |
| 339 | // Evaluate only this particular predicate and nothing else. |
| 340 | predicateAllowList := func(sym ast.PredicateSym) bool { |
| 341 | return sym == ast.PredicateSym{"path", 2} |
| 342 | } |
| 343 | opt.predicateAllowList = &predicateAllowList |
| 344 | }); err != nil { |
| 345 | t.Errorf("Program evaluation failed %v program %v", err, program) |
| 346 | return |
| 347 | } |
| 348 | |
| 349 | expected := []ast.Atom{ |
| 350 | atom("node(/a)"), |
| 351 | atom("node(/b)"), |
| 352 | atom("node(/c)"), |
| 353 | atom("edge(/a,/b)"), |
| 354 | atom("edge(/b,/c)"), |
| 355 | atom("label(/a, 100)"), |
| 356 | atom("path(/a,/b)"), |
| 357 | atom("path(/a,/c)"), |
| 358 | atom("path(/b,/c)"), |
| 359 | } |
| 360 | |
| 361 | for _, fact := range expected { |
| 362 | if !store.Contains(fact) { |
| 363 | t.Errorf("expected fact %v in store %v", fact, store) |
| 364 | } |
| 365 | } |
| 366 | if store.EstimateFactCount() > len(expected) { |
| 367 | t.Errorf("extra facts: %v", store) |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | func TestManyPaths(t *testing.T) { |
| 372 | store := factstore.NewSimpleInMemoryStore() |
nothing calls this directly
no test coverage detected