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

Function TestManyPaths

engine/seminaivebottomup_test.go:371–400  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

369}
370
371func TestManyPaths(t *testing.T) {
372 store := factstore.NewSimpleInMemoryStore()
373 store.Add(atom("node(/a)"))
374 store.Add(atom("label(/a, 100)"))
375
376 for i := 1; i <= 10; i++ {
377 store.Add(atom(fmt.Sprintf("node(/b%d)", i)))
378 store.Add(atom(fmt.Sprintf("node(/c%d)", i)))
379 store.Add(atom(fmt.Sprintf("edge(/a,/b%d)", i)))
380 store.Add(atom(fmt.Sprintf("edge(/b%d, /c%d)", i, i)))
381 }
382 store.Add(atom("edge(/c9,/b9)"))
383 if err := analyzeAndEvalProgram(t, program, store); err != nil {
384 t.Errorf("Program evaluation failed %v program %v", err, program)
385 return
386 }
387
388 expected := []ast.Atom{
389 atom("path(/a,/c2)"),
390 atom("path(/c9,/c9)"),
391 atom("in_cycle_eq(/c9)"),
392 atom("in_between(/a,/c9)"),
393 }
394
395 for _, fact := range expected {
396 if !store.Contains(fact) {
397 t.Errorf("expected fact %v in store %v", fact, store)
398 }
399 }
400}
401
402func TestNonLinear(t *testing.T) {
403 store := factstore.NewSimpleInMemoryStore()

Callers

nothing calls this directly

Calls 5

AddMethod · 0.95
ContainsMethod · 0.95
NewSimpleInMemoryStoreFunction · 0.92
analyzeAndEvalProgramFunction · 0.85
atomFunction · 0.70

Tested by

no test coverage detected