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

Function TestCheckRuleBindsByDecl

analysis/validation_test.go:149–172  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

147}
148
149func TestCheckRuleBindsByDecl(t *testing.T) {
150 d, err := ast.NewDecl(
151 atom("bar(Struct, FieldValue)"),
152 []ast.Atom{
153 atom("mode('+', '+')"),
154 atom("mode('+', '-')"),
155 },
156 []ast.BoundDecl{ast.NewBoundDecl(ast.AnyBound), ast.NewBoundDecl(ast.AnyBound)},
157 nil)
158 if err != nil {
159 t.Fatal(err)
160 }
161
162 analyzer, err := New(nil, []ast.Decl{d}, ErrorForBoundsMismatch)
163 if err != nil {
164 t.Fatalf("New(nil, %v, ErrorForBoundsMismatch) returned unexpected error: %v", d, err)
165 }
166
167 // :match_field expects first argument to be bound
168 clause := clause("bar(S, F) :- :match_field(S, /random, F).")
169 if err := analyzer.CheckRule(clause); err != nil {
170 t.Errorf("CheckRule(%v) returned unexpected error: %v", clause, err)
171 }
172}
173
174func TestCheckRulePositiveExtraFun(t *testing.T) {
175 tests := []ast.Clause{

Callers

nothing calls this directly

Calls 6

NewDeclFunction · 0.92
NewBoundDeclFunction · 0.92
CheckRuleMethod · 0.80
atomFunction · 0.70
NewFunction · 0.70
clauseFunction · 0.70

Tested by

no test coverage detected