(t *testing.T)
| 604 | } |
| 605 | |
| 606 | func TestBoundsAnalyzer(t *testing.T) { |
| 607 | tests := []boundsTestCase{ |
| 608 | newBoundsTestCase(t, []ast.Clause{ |
| 609 | clause("foo(X) :- bar(X), X = 3."), |
| 610 | }, []ast.Decl{ |
| 611 | makeSimpleDecl(atom("foo(X)"), ast.NumberBound), |
| 612 | makeSimpleDecl(atom("bar(X)"), ast.NumberBound), |
| 613 | }), |
| 614 | newBoundsTestCase(t, []ast.Clause{ |
| 615 | clause("foo(X, Y, Z) :- bar(X, Y), baz(Y, Z)."), |
| 616 | }, []ast.Decl{ |
| 617 | makeSimpleDecl(atom("foo(X, Y, Z)"), ast.StringBound, ast.NumberBound, ast.NumberBound), |
| 618 | makeSimpleDecl(atom("bar(A, B)"), ast.StringBound, ast.NumberBound), |
| 619 | makeSimpleDecl(atom("baz(E, F)"), ast.NumberBound, ast.NumberBound), |
| 620 | }), |
| 621 | newBoundsTestCase(t, []ast.Clause{ |
| 622 | clause("foo(X, X) :- bar(X)."), |
| 623 | }, []ast.Decl{ |
| 624 | makeSimpleDecl(atom("foo(X, Y)"), ast.NumberBound, ast.NumberBound), |
| 625 | makeSimpleDecl(atom("bar(A)"), ast.NumberBound), |
| 626 | }), |
| 627 | newBoundsTestCase(t, []ast.Clause{ |
| 628 | clause("foo(X) :- bar(X)."), |
| 629 | clause("foo(X) :- baz(X)."), |
| 630 | }, []ast.Decl{ |
| 631 | makeSimpleDecl(atom("foo(X)"), ast.ApplyFn{symbols.UnionType, []ast.BaseTerm{ast.StringBound, ast.NumberBound}}), |
| 632 | makeSimpleDecl(atom("bar(A)"), ast.StringBound), |
| 633 | makeSimpleDecl(atom("baz(A)"), ast.NumberBound), |
| 634 | }), |
| 635 | newBoundsTestCase(t, []ast.Clause{ |
| 636 | clause("foo(X) :- bar(X)."), |
| 637 | clause("foo(X) :- baz(X)."), |
| 638 | }, []ast.Decl{ |
| 639 | makeSimpleDecl(atom("foo(X)"), ast.NumberBound), |
| 640 | makeSimpleDecl(atom("bar(A)"), ast.NumberBound), |
| 641 | makeSimpleDecl(atom("baz(A)"), ast.NumberBound), |
| 642 | }), |
| 643 | newBoundsTestCase(t, []ast.Clause{ |
| 644 | clause("foo(1)."), |
| 645 | clause("foo(X) :- bar(X)."), |
| 646 | clause("bar(X) :- foo(X)."), |
| 647 | }, []ast.Decl{ |
| 648 | makeSimpleDecl(atom("foo(X)"), ast.NumberBound), |
| 649 | makeSimpleDecl(atom("bar(A)"), ast.NumberBound), |
| 650 | }), |
| 651 | newBoundsTestCase(t, []ast.Clause{ |
| 652 | clause("foo(1)."), |
| 653 | clause("foo(['a'])."), |
| 654 | clause("foo(X) :- bar(X)."), |
| 655 | clause("bar(X) :- foo(X)."), |
| 656 | }, []ast.Decl{ |
| 657 | ast.Decl{ |
| 658 | DeclaredAtom: atom("foo(X)"), |
| 659 | Bounds: []ast.BoundDecl{ |
| 660 | ast.NewBoundDecl(ast.NumberBound), |
| 661 | ast.NewBoundDecl(symbols.NewListType(ast.StringBound)), |
| 662 | }, |
| 663 | }, |
nothing calls this directly
no test coverage detected