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

Function TestSimpleEval

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

Source from the content-addressed store, hash-verified

290}
291
292func TestSimpleEval(t *testing.T) {
293 store := factstore.NewSimpleInMemoryStore()
294 store.Add(atom("node(/a)"))
295 store.Add(atom("node(/b)"))
296 store.Add(atom("label(/b, 100)"))
297 store.Add(atom("node(/c)"))
298 store.Add(atom("node(/d)"))
299 store.Add(atom("edge(/a,/b)"))
300 store.Add(atom("edge(/b,/c)"))
301 store.Add(atom("edge(/c,/d)"))
302
303 if err := analyzeAndEvalProgram(t, program, store); err != nil {
304 t.Errorf("Program evaluation failed %v program %v", err, program)
305 return
306 }
307
308 expected := []ast.Atom{
309 atom("path(/a,/b)"),
310 atom("path(/a,/c)"),
311 atom("path(/a,/d)"),
312 atom("path(/b,/c)"),
313 atom("path(/b,/d)"),
314 atom("path(/c,/d)"),
315 atom("neighbor_label(/a, /b, 100)"),
316 atom("has_neighbor(/c)"),
317 atom("expanded_stuff(1)"),
318 atom("expanded_stuff(2)"),
319 atom("expanded_stuff(3)"),
320 }
321
322 for _, fact := range expected {
323 if !store.Contains(fact) {
324 t.Errorf("expected fact %v in store %v", fact, store)
325 }
326 }
327}
328
329func TestSimpleEvalDefer(t *testing.T) {
330 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