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

Function TestRewriteClauseDefinedPreviously

analysis/rewriteclause_test.go:70–95  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

68}
69
70func TestRewriteClauseDefinedPreviously(t *testing.T) {
71 scanDecl, err := ast.NewSyntheticDecl(atom("scan(X)"))
72 if err != nil {
73 t.Fatal(err)
74 }
75 d, err := ast.NewDecl(
76 atom("bar(Z)"),
77 []ast.Atom{
78 atom("reflects(/bar)"),
79 },
80 []ast.BoundDecl{ast.NewBoundDecl(name("/bar"))},
81 nil)
82 if err != nil {
83 t.Fatal(err)
84 }
85 decls := map[ast.PredicateSym]*ast.Decl{
86 ast.PredicateSym{"scan", 1}: &scanDecl,
87 ast.PredicateSym{"bar", 1}: &d,
88 }
89 clause := clause("foo(X) :- scan(X), bar(X).")
90 got := RewriteClause(decls, clause)
91 want := atom(":match_prefix(X, /bar)")
92 if len(got.Premises) != 2 || !got.Premises[1].Equals(want) {
93 t.Errorf("RewriteClause(%v, %v)=%v want %v", decls, clause, got, want)
94 }
95}
96
97func TestRewriteClauseDelayNegAtoms(t *testing.T) {
98 clause := ast.Clause{

Callers

nothing calls this directly

Calls 8

NewSyntheticDeclFunction · 0.92
NewDeclFunction · 0.92
NewBoundDeclFunction · 0.92
RewriteClauseFunction · 0.85
atomFunction · 0.70
nameFunction · 0.70
clauseFunction · 0.70
EqualsMethod · 0.65

Tested by

no test coverage detected