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

Function TestRewriteClauseInputMode

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

Source from the content-addressed store, hash-verified

47}
48
49func TestRewriteClauseInputMode(t *testing.T) {
50 d, err := ast.NewDecl(
51 atom("bar(Z)"),
52 []ast.Atom{
53 atom("reflects(/bar)"),
54 atom("mode('+')"),
55 },
56 []ast.BoundDecl{ast.NewBoundDecl(name("/bar"))},
57 nil)
58 if err != nil {
59 t.Fatal(err)
60 }
61 decls := map[ast.PredicateSym]*ast.Decl{ast.PredicateSym{"bar", 1}: &d}
62 clause := clause("foo(X) :- bar(X).")
63 got := RewriteClause(decls, clause)
64 want := atom(":match_prefix(X, /bar)")
65 if len(got.Premises) != 1 || !got.Premises[0].Equals(want) {
66 t.Errorf("RewriteClause(%v, %v)=%v want %v", decls, clause, got, want)
67 }
68}
69
70func TestRewriteClauseDefinedPreviously(t *testing.T) {
71 scanDecl, err := ast.NewSyntheticDecl(atom("scan(X)"))

Callers

nothing calls this directly

Calls 7

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