(t *testing.T)
| 771 | } |
| 772 | |
| 773 | func TestBoundsAnalyzerNegative(t *testing.T) { |
| 774 | tests := []boundsTestCase{ |
| 775 | newBoundsTestCase(t, []ast.Clause{ |
| 776 | clause("foo(X, Y, Z) :- bar(X, Y), baz(Y, Z)."), |
| 777 | }, []ast.Decl{ |
| 778 | makeSimpleDecl(atom("foo(X, Y, Z)"), ast.StringBound, ast.StringBound, ast.NumberBound), |
| 779 | makeSimpleDecl(atom("bar(A, B)"), ast.StringBound, ast.NumberBound), |
| 780 | makeSimpleDecl(atom("baz(E, F)"), ast.NumberBound, ast.NumberBound), |
| 781 | }), |
| 782 | newBoundsTestCase(t, []ast.Clause{ |
| 783 | clause("foo('hello')."), |
| 784 | }, []ast.Decl{ |
| 785 | makeSimpleDecl(atom("foo(Num)"), ast.NumberBound), |
| 786 | }), |
| 787 | newBoundsTestCase(t, []ast.Clause{ |
| 788 | clause("foo(X) :- bar(X), X = 'hello'."), |
| 789 | }, []ast.Decl{ |
| 790 | makeSimpleDecl(atom("foo(X)"), ast.NumberBound), |
| 791 | makeSimpleDecl(atom("bar(X)"), ast.NumberBound), |
| 792 | }), |
| 793 | newBoundsTestCase(t, []ast.Clause{ |
| 794 | clause("foo(X) :- bar(X), :lt(X, 10)."), |
| 795 | }, []ast.Decl{ |
| 796 | makeSimpleDecl(atom("foo(X)"), ast.StringBound), |
| 797 | makeSimpleDecl(atom("bar(X)"), ast.StringBound), |
| 798 | }), |
| 799 | newBoundsTestCase(t, []ast.Clause{ |
| 800 | clause("foo(X, Y) :- bar(X, Y)."), |
| 801 | }, []ast.Decl{ |
| 802 | makeSimpleDecl(atom("foo(X, Y)"), ast.StringBound, ast.NumberBound), |
| 803 | makeSimpleDecl(atom("bar(A, B)"), ast.AnyBound, ast.NumberBound), |
| 804 | }), |
| 805 | newBoundsTestCase(t, []ast.Clause{ |
| 806 | clause("foo(X, Y) :- bar(X, Y), bar(X, Z), bar(Z, Y)."), |
| 807 | }, []ast.Decl{ |
| 808 | makeSimpleDecl(atom("foo(X, Y)"), ast.StringBound, ast.NumberBound), |
| 809 | makeSimpleDecl(atom("bar(A, B)"), ast.StringBound, ast.NumberBound), |
| 810 | }), |
| 811 | newBoundsTestCase(t, []ast.Clause{ |
| 812 | clause("foo(X) :- bar(X)."), |
| 813 | clause("foo(X) :- baz(X)."), |
| 814 | }, []ast.Decl{ |
| 815 | makeSimpleDecl(atom("foo(X)"), ast.NumberBound), |
| 816 | makeSimpleDecl(atom("bar(A)"), ast.StringBound), |
| 817 | makeSimpleDecl(atom("baz(A)"), ast.NumberBound), |
| 818 | }), |
| 819 | newBoundsTestCase(t, []ast.Clause{ |
| 820 | clause("foo(X) :- bar(X, Y), baz(['hello'])."), |
| 821 | }, []ast.Decl{ |
| 822 | makeSimpleDecl(atom("foo(X)"), ast.NumberBound), |
| 823 | makeSimpleDecl(atom("bar(A, B)"), ast.StringBound, ast.StringBound), |
| 824 | makeSimpleDecl(atom("baz(A)"), symbols.NewListType(ast.NumberBound)), |
| 825 | }), |
| 826 | newBoundsTestCase(t, []ast.Clause{ |
| 827 | clause("bar(X) :- Z = { /foo: 'a' }, :match_field(Z, /baz, X)."), |
| 828 | }, []ast.Decl{ |
| 829 | makeSimpleDecl(atom("bar(S)"), ast.StringBound), |
| 830 | }), |
nothing calls this directly
no test coverage detected