Skip to content

Commit b0ee4d6

Browse files
committed
feat: add Level 3 signature freezing tests for reexport API
Add comprehensive tests to freeze API signatures across all reexport files: - Type hierarchy checks for inheritance relationships - Method signature checks with has() for key functions - Missing symbols: solve and plot! now properly tested - All 503 reexport tests passing This will detect breakages when CTX packages change their APIs. Files modified: - test/suite/reexport/test_ctbase.jl: exception inheritance - test/suite/reexport/test_ctdirect.jl: discretizer hierarchy + discretize signature - test/suite/reexport/test_ctflows.jl: Hamiltonian types + Lift/Flow signatures - test/suite/reexport/test_ctmodels.jl: plot! + OCP types + serialization signatures - test/suite/reexport/test_ctsolvers.jl: solver/modeler/parameter hierarchy + DOCP signatures - test/suite/reexport/test_optimalcontrol.jl: solve + methods signatures
1 parent 4cb53ce commit b0ee4d6

7 files changed

Lines changed: 138 additions & 224 deletions

File tree

docs/src/api/private.md

Lines changed: 0 additions & 223 deletions
This file was deleted.

test/suite/reexport/test_ctbase.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ function test_ctbase()
3838
Test.@test T isa DataType
3939
end
4040
end
41+
42+
Test.@testset "Type Hierarchy" begin
43+
Test.@testset "Exception inheritance" begin
44+
for T in (
45+
OptimalControl.IncorrectArgument,
46+
OptimalControl.PreconditionError,
47+
OptimalControl.NotImplemented,
48+
OptimalControl.ParsingError,
49+
OptimalControl.AmbiguousDescription,
50+
OptimalControl.ExtensionError,
51+
)
52+
Test.@test T <: OptimalControl.CTException
53+
end
54+
end
55+
end
4156
end
4257
end
4358

test/suite/reexport/test_ctdirect.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ function test_ctdirect()
2929
Test.@test isdefined(CurrentModule, :discretize)
3030
Test.@test discretize isa Function
3131
end
32+
33+
Test.@testset "Type Hierarchy" begin
34+
Test.@test OptimalControl.Collocation <: OptimalControl.AbstractDiscretizer
35+
end
36+
37+
Test.@testset "Method Signatures" begin
38+
Test.@testset "discretize" begin
39+
Test.@test hasmethod(
40+
discretize,
41+
Tuple{OptimalControl.AbstractModel,OptimalControl.AbstractDiscretizer},
42+
)
43+
end
44+
end
3245
end
3346
end
3447

test/suite/reexport/test_ctflows.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module TestCtflows
99

1010
using Test: Test
1111
using OptimalControl # using is mandatory since we test exported symbols
12+
import CTFlows # needed for abstract type checks
1213

1314
const VERBOSE = isdefined(Main, :TestOptions) ? Main.TestOptions.VERBOSE : true
1415
const SHOWTIMING = isdefined(Main, :TestOptions) ? Main.TestOptions.SHOWTIMING : true
@@ -45,6 +46,22 @@ function test_ctflows()
4546
Test.@test isdefined(OptimalControl, Symbol("@Lie"))
4647
Test.@test isdefined(CurrentModule, Symbol("@Lie"))
4748
end
49+
50+
Test.@testset "Type Hierarchy" begin
51+
Test.@test OptimalControl.Hamiltonian <: CTFlows.AbstractHamiltonian
52+
Test.@test OptimalControl.HamiltonianLift <: CTFlows.AbstractHamiltonian
53+
Test.@test OptimalControl.HamiltonianVectorField <: CTFlows.AbstractVectorField
54+
end
55+
56+
Test.@testset "Method Signatures" begin
57+
Test.@testset "Lift" begin
58+
Test.@test hasmethod(Lift, Tuple{CTFlows.VectorField})
59+
Test.@test hasmethod(Lift, Tuple{Function})
60+
end
61+
Test.@testset "Flow" begin
62+
Test.@test hasmethod(Flow, Tuple{Vararg{Any}})
63+
end
64+
end
4865
end
4966
end
5067

test/suite/reexport/test_ctmodels.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ function test_ctmodels()
2727
Test.@test isdefined(OptimalControl, :plot)
2828
Test.@test isdefined(CurrentModule, :plot)
2929
Test.@test plot isa Function
30+
Test.@test isdefined(OptimalControl, :plot!)
31+
Test.@test isdefined(CurrentModule, :plot!)
32+
Test.@test plot! isa Function
3033
end
3134

3235
Test.@testset "Initial Guess Types" begin
@@ -184,6 +187,25 @@ function test_ctmodels()
184187
end
185188
end
186189
end
190+
191+
Test.@testset "Type Hierarchy" begin
192+
Test.@test OptimalControl.Model <: OptimalControl.AbstractModel
193+
Test.@test OptimalControl.Solution <: OptimalControl.AbstractSolution
194+
Test.@test OptimalControl.InitialGuess <: OptimalControl.AbstractInitialGuess
195+
end
196+
197+
Test.@testset "Method Signatures" begin
198+
Test.@testset "export_ocp_solution" begin
199+
Test.@test hasmethod(
200+
export_ocp_solution, Tuple{OptimalControl.AbstractSolution}
201+
)
202+
end
203+
Test.@testset "import_ocp_solution" begin
204+
Test.@test hasmethod(
205+
import_ocp_solution, Tuple{OptimalControl.AbstractModel}
206+
)
207+
end
208+
end
187209
end
188210
end
189211

test/suite/reexport/test_ctsolvers.jl

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module TestCtsolvers
1010
using Test: Test
1111
using CTSolvers: CTSolvers
1212
using OptimalControl # using is mandatory since we test exported symbols
13+
import SolverCore # needed for ocp_solution signature check
1314

1415
const VERBOSE = isdefined(Main, :TestOptions) ? Main.TestOptions.VERBOSE : true
1516
const SHOWTIMING = isdefined(Main, :TestOptions) ? Main.TestOptions.SHOWTIMING : true
@@ -155,6 +156,52 @@ function test_ctsolvers()
155156
Test.@test !isdefined(OptimalControl, :get_parameter_type)
156157
Test.@test !isdefined(OptimalControl, :available_parameters)
157158
end
159+
160+
Test.@testset "Type Hierarchy" begin
161+
Test.@testset "Modelers" begin
162+
Test.@test OptimalControl.ADNLP <: OptimalControl.AbstractNLPModeler
163+
Test.@test OptimalControl.Exa <: OptimalControl.AbstractNLPModeler
164+
end
165+
Test.@testset "Solvers" begin
166+
Test.@test OptimalControl.Ipopt <: OptimalControl.AbstractNLPSolver
167+
Test.@test OptimalControl.MadNLP <: OptimalControl.AbstractNLPSolver
168+
Test.@test OptimalControl.MadNCL <: OptimalControl.AbstractNLPSolver
169+
Test.@test OptimalControl.Knitro <: OptimalControl.AbstractNLPSolver
170+
end
171+
Test.@testset "Parameters" begin
172+
Test.@test OptimalControl.CPU <: CTSolvers.AbstractStrategyParameter
173+
Test.@test OptimalControl.GPU <: CTSolvers.AbstractStrategyParameter
174+
end
175+
end
176+
177+
Test.@testset "Method Signatures" begin
178+
Test.@testset "ocp_model" begin
179+
Test.@test hasmethod(ocp_model, Tuple{OptimalControl.DiscretizedModel})
180+
end
181+
Test.@testset "nlp_model" begin
182+
Test.@test hasmethod(
183+
nlp_model,
184+
Tuple{
185+
OptimalControl.DiscretizedModel,
186+
Any,
187+
OptimalControl.AbstractNLPModeler,
188+
},
189+
)
190+
end
191+
Test.@testset "ocp_solution" begin
192+
Test.@test hasmethod(
193+
ocp_solution,
194+
Tuple{
195+
OptimalControl.DiscretizedModel,
196+
SolverCore.AbstractExecutionStats,
197+
OptimalControl.AbstractNLPModeler,
198+
},
199+
)
200+
end
201+
Test.@testset "describe" begin
202+
Test.@test hasmethod(describe, Tuple{Symbol})
203+
end
204+
end
158205
end
159206
end
160207

0 commit comments

Comments
 (0)