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

Function TestEmptyArrayProgram

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

Source from the content-addressed store, hash-verified

677}
678
679func TestEmptyArrayProgram(t *testing.T) {
680 store := factstore.NewSimpleInMemoryStore()
681 program := []ast.Clause{
682 clause(`a_list([]).`),
683 }
684 if err := analyzeAndEvalProgram(t, program, store); err != nil {
685 t.Errorf("Program evaluation failed %v program %v", err, program)
686 return
687 }
688
689 goal := atom("a_list(A)")
690 facts := make(map[uint64]ast.Atom)
691 if err := store.GetFacts(goal, func(storefact ast.Atom) error {
692 subst, err := unionfind.UnifyTerms(goal.Args, storefact.Args)
693 if err != nil {
694 return nil
695 }
696 fact := goal.ApplySubst(subst).(ast.Atom)
697 facts[fact.Hash()] = fact
698 return nil
699 }); err != nil {
700 t.Errorf("GetFacts(%v): %v", goal, err)
701 }
702 if got, want := len(facts), 1; got != want {
703 t.Errorf("GetFacts: %d!=%d got: %v", got, want, facts)
704 }
705}
706
707func TestTransformMax(t *testing.T) {
708 for _, tt := range []struct {

Callers

nothing calls this directly

Calls 8

GetFactsMethod · 0.95
NewSimpleInMemoryStoreFunction · 0.92
UnifyTermsFunction · 0.92
analyzeAndEvalProgramFunction · 0.85
clauseFunction · 0.70
atomFunction · 0.70
ApplySubstMethod · 0.65
HashMethod · 0.65

Tested by

no test coverage detected