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

Function TestManyPathsNaive

engine/naivebottomup_test.go:74–101  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

72}
73
74func TestManyPathsNaive(t *testing.T) {
75 store := factstore.NewSimpleInMemoryStore()
76 store.Add(atom("node(/a)"))
77 for i := 1; i <= 10; i++ {
78 store.Add(atom(fmt.Sprintf("node(/b%d)", i)))
79 store.Add(atom(fmt.Sprintf("node(/c%d)", i)))
80 store.Add(atom(fmt.Sprintf("edge(/a,/b%d)", i)))
81 store.Add(atom(fmt.Sprintf("edge(/b%d, /c%d)", i, i)))
82 }
83 store.Add(atom("edge(/c9,/b9)"))
84 if err := EvalProgramNaive(naiveProgram, store); err != nil {
85 t.Errorf("Program evaluation failed %v program %v", err, program)
86 return
87 }
88
89 expected := []ast.Atom{
90 atom("path(/a,/c2)"),
91 atom("path(/c9,/c9)"),
92 atom("in_cycle_eq(/c9)"),
93 atom("in_between(/a,/c9)"),
94 }
95
96 for _, fact := range expected {
97 if !store.Contains(fact) {
98 t.Errorf("expected fact %v in store %v", fact, store)
99 }
100 }
101}
102
103func TestBuiltinNaive(t *testing.T) {
104 store := factstore.NewSimpleInMemoryStore()

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected