MCPcopy Index your code
hub / github.com/google/mangle / TestStratificationNegative

Function TestStratificationNegative

analysis/stratification_test.go:183–219  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

181}
182
183func TestStratificationNegative(t *testing.T) {
184 tests := []func() (*ProgramInfo, error){
185 func() (*ProgramInfo, error) {
186 return analyze([]ast.Clause{
187 clause("bar(/baz)."),
188 clause("foo(X) :- !sna(X), bar(X)."),
189 clause("sna(X) :- !foo(X), bar(X)."),
190 })
191 },
192 func() (*ProgramInfo, error) {
193 return analyze([]ast.Clause{
194 clause("yes(/yes)."),
195 clause("no(/no)."),
196 clause("yesorno(X) :- !yesorno(X), yes(X)."),
197 clause("yesorno(X) :- yesorno(X), no(X)."),
198 })
199 },
200 func() (*ProgramInfo, error) {
201 return analyze([]ast.Clause{
202 clause("rec(/yes)."),
203 clause("rec(Z) :- rec(X) |> do fn:group_by(), let Z = fn:count()."),
204 })
205 },
206 }
207
208 for _, testprogram := range tests {
209 program, err := testprogram()
210 if err != nil {
211 panic(fmt.Errorf("test case did not pass %v", err))
212 }
213 nodes, predtostratum, err := Stratify(Program{
214 program.EdbPredicates, program.IdbPredicates, program.Rules})
215 if err == nil {
216 t.Errorf("expected stratification to fail, but succeeded %v %v", nodes, predtostratum)
217 }
218 }
219}

Callers

nothing calls this directly

Calls 3

analyzeFunction · 0.85
StratifyFunction · 0.85
clauseFunction · 0.70

Tested by

no test coverage detected