@@ -10,10 +10,17 @@ function SemialgebraicSets.default_gröbner_basis_algorithm(p, ::DummySolver)
1010end 
1111SemialgebraicSets. promote_for (:: Type{T} , :: Type{DummySolver} ) where  {T} =  T
1212
13+ function  _test_polynomial_API (set, vars)
14+     mono =  prod (vars)
15+     @test  @inferred (variables (set)) ==  variables (mono)
16+     @test  @inferred (monomial_type (typeof (set))) ==  monomial_type (typeof (mono))
17+ end 
18+ 
1319function  runtests ()
1420    Main. Mod. @polyvar  x y
1521    @test  isa (FullSpace (), FullSpace)
1622    V =  @set  x *  y ==  1 
23+     _test_polynomial_API (V, (x, y))
1724    @test  V isa  AlgebraicSet{Rational{BigInt}}
1825    @test_throws  ArgumentError add_inequality! (V, x *  y)
1926    @testset  " Basic"   begin 
@@ -22,6 +29,7 @@ function runtests()
2229        add_inequality! (S, x +  y -  1 )
2330        #  Algebraic set forces `Rational{BigInt}`
2431        @test  S isa  BasicSemialgebraicSet{Rational{BigInt}}
32+         _test_polynomial_API (S, (x, y))
2533        @test  S ==  basic_semialgebraic_set (S. V, S. p)
2634        @test  sprint (show, S) == 
2735              " { (x, y) | -y + x = 0, -y + x^2 = 0, -1//1 + x^2*y ≥ 0, -1//1 + y + x ≥ 0 }" 
@@ -49,29 +57,35 @@ function runtests()
4957                  1.0 x^ 2  *  y >=  0  && 
5058                  (6  //  3 ) *  x^ 2  *  y ==  - y && 
5159                  1.5 x +  y >=  0 )
60+             _test_polynomial_API (S, (x, y))
5261            S2 =  S ∩  V
5362            S3 =  V ∩  S
5463            @test  inequalities (S2) ==  inequalities (S3) ==  S. p
5564            @test  equalities (S2) ==  S3. V. I. p
5665        end 
5766
5867        T =  (@set  x *  y^ 2  ==  - 1  &&  x^ 2  +  y^ 2  <=  1 )
68+         _test_polynomial_API (T, (x, y))
5969        V2 =  @set  T. V &&  V &&  x +  y ==  2.0 
70+         _test_polynomial_API (V2, (x, y))
6071        @test  V2 isa  AlgebraicSet
6172        @test  V2. I. p ==  [equalities (T); equalities (V); x +  y -  2.0 ]
6273        S4 =  @set  S &&  T
74+         _test_polynomial_API (S4, (x, y))
6375        @test  S4. p ==  [S. p; inequalities (T)]
6476        @test  equalities (S4) ==  [S. V. I. p; T. V. I. p]
6577
6678        @testset  " Different variables"   begin 
6779            T =  (@set  x ==  x^ 2  &&  y <=  y^ 2 )
80+             _test_polynomial_API (T, (x, y))
6881            @test  sprint (show, T) ==  " { (x, y) | x - x^2 = 0, -y + y^2 ≥ 0 }" 
6982            @test  sprint (show, MIME " text/plain"  (), T) == 
7083                  " Basic semialgebraic Set defined by 1 equalitty\n  x - x^2 = 0\n 1 inequalitty\n  -y + y^2 ≥ 0\n " 
7184        end 
7285    end 
7386    @testset  " Basic with no equality"   begin 
7487        S =  @set  x +  y ≥  1  &&  x ≤  y
88+         _test_polynomial_API (S, (x, y))
7589        @test  sprint (show, S) ==  " { (x, y) | -1 + y + x ≥ 0, y - x ≥ 0 }" 
7690        @test  sprint (show, MIME " text/plain"  (), S) ==  """ 
7791Basic semialgebraic Set defined by no equality 
@@ -98,6 +112,7 @@ Algebraic Set defined by no equality
98112    end 
99113    @testset  " Basic with fixed variables"   begin 
100114        S =  @set  x ==  1  &&  x ≤  x^ 2 
115+         _test_polynomial_API (S, (x,))
101116        @test  sprint (show, S) ==  " { (x) | -1 + x = 0, -x + x^2 ≥ 0 }" 
102117        @test  sprint (show, MIME " text/plain"  (), S) == 
103118              " Basic semialgebraic Set defined by 1 equalitty\n  -1 + x = 0\n 1 inequalitty\n  -x + x^2 ≥ 0\n " 
@@ -106,6 +121,7 @@ Algebraic Set defined by no equality
106121              " Algebraic Set defined by 1 equalitty\n  -1 + x = 0\n " 
107122
108123        S =  @set  x ==  1  &&  x ≤  y &&  2  ==  y
124+         _test_polynomial_API (S, (x, y))
109125        @test  S isa  BasicSemialgebraicSet{Int}
110126        @test  S. V isa  FixedVariablesSet{<: AbstractVariable ,Int}
111127        @test  rem (x +  y, ideal (S. V)) ==  3 
@@ -118,6 +134,7 @@ Algebraic Set defined by no equality
118134        @test  rem (x +  y, ideal (Sf. V)) ==  3 
119135
120136        S =  @set  x ==  1  &&  x ≤  y &&  2  ==  y &&  1  ==  x
137+         _test_polynomial_API (S, (x, y))
121138        @test  S isa  BasicSemialgebraicSet{Int}
122139        @test  S. V isa  FixedVariablesSet{<: AbstractVariable ,Int}
123140        @test  rem (x +  y, ideal (S. V)) ==  3 
@@ -136,6 +153,7 @@ Algebraic Set defined by no equality
136153            )
137154                @test  S isa  BasicSemialgebraicSet{Int}
138155                @test  S. V isa  FixedVariablesSet{<: AbstractVariable ,Int}
156+                 _test_polynomial_API (S, (x, y))
139157                @test  isempty (S. V)
140158                @test  iszero (length (S. V))
141159                @test  isempty (collect (S. V))
@@ -154,6 +172,7 @@ Algebraic Set defined by no equality
154172        ]
155173            @test  S isa  BasicSemialgebraicSet{Rational{BigInt}}
156174            @test  S. V isa  AlgebraicSet{Rational{BigInt}}
175+             _test_polynomial_API (S, (x, y))
157176        end 
158177
159178        solver =  DummySolver ()
@@ -167,6 +186,7 @@ Algebraic Set defined by no equality
167186        ]
168187            @test  S isa  BasicSemialgebraicSet{Rational{BigInt}}
169188            @test  S. V isa  AlgebraicSet{Rational{BigInt}}
189+             _test_polynomial_API (S, (x, y))
170190            @test  S. V. solver ===  solver
171191        end 
172192    end 
0 commit comments