|
106 | 106 | @test isconcretetype(ode15s_test) |
107 | 107 | @test isconcretetype(ode15i_test) |
108 | 108 | end |
| 109 | + |
| 110 | + @testset "Type compatibility functions" begin |
| 111 | + # Test the type compatibility check functions |
| 112 | + # These mirror the actual module implementations |
| 113 | + # Note: BigInt is NOT accepted because MATLAB doesn't support arbitrary precision |
| 114 | + |
| 115 | + _is_matlab_compatible_eltype_test(::Type{Float64})::Bool = true |
| 116 | + _is_matlab_compatible_eltype_test(::Type{<:Union{Int8, Int16, Int32, Int64, Int128}})::Bool = true |
| 117 | + _is_matlab_compatible_eltype_test(::Type{<:Union{UInt8, UInt16, UInt32, UInt64, UInt128}})::Bool = true |
| 118 | + _is_matlab_compatible_eltype_test(::Type{<:Complex{Float64}})::Bool = true |
| 119 | + _is_matlab_compatible_eltype_test(::Type)::Bool = false |
| 120 | + |
| 121 | + # Test return types are Bool |
| 122 | + @test _is_matlab_compatible_eltype_test(Float64) === true |
| 123 | + @test _is_matlab_compatible_eltype_test(Int64) === true |
| 124 | + @test _is_matlab_compatible_eltype_test(UInt64) === true |
| 125 | + @test _is_matlab_compatible_eltype_test(Complex{Float64}) === true |
| 126 | + @test _is_matlab_compatible_eltype_test(BigFloat) === false |
| 127 | + @test _is_matlab_compatible_eltype_test(BigInt) === false |
| 128 | + @test _is_matlab_compatible_eltype_test(Float32) === false |
| 129 | + |
| 130 | + # JET @test_opt analysis for type stability |
| 131 | + if HAS_JET |
| 132 | + @testset "JET @test_opt type stability" begin |
| 133 | + # Test type stability of _is_matlab_compatible_eltype |
| 134 | + @test_opt _is_matlab_compatible_eltype_test(Float64) |
| 135 | + @test_opt _is_matlab_compatible_eltype_test(Int64) |
| 136 | + @test_opt _is_matlab_compatible_eltype_test(BigFloat) |
| 137 | + end |
| 138 | + end |
| 139 | + end |
| 140 | + |
| 141 | + @testset "Return type inference" begin |
| 142 | + # Test that return types can be inferred correctly |
| 143 | + function buildDEStats_test2(solverstats::Dict{String, <:Any})::DiffEqBase.Stats |
| 144 | + destats = DiffEqBase.Stats(0) |
| 145 | + destats.nf = Int(get(solverstats, "nfevals", 0)) |
| 146 | + destats.nreject = Int(get(solverstats, "nfailed", 0)) |
| 147 | + destats.naccept = Int(get(solverstats, "nsteps", 0)) |
| 148 | + destats.nsolve = Int(get(solverstats, "nsolves", 0)) |
| 149 | + destats.njacs = Int(get(solverstats, "npds", 0)) |
| 150 | + destats.nw = Int(get(solverstats, "ndecomps", 0)) |
| 151 | + destats |
| 152 | + end |
| 153 | + |
| 154 | + # Verify return type is inferred as concrete |
| 155 | + return_types = Base.return_types(buildDEStats_test2, (Dict{String, Any},)) |
| 156 | + @test length(return_types) == 1 |
| 157 | + @test return_types[1] == DiffEqBase.Stats |
| 158 | + end |
109 | 159 | end |
0 commit comments