Skip to content

Commit 25d40ad

Browse files
Fix test compatibility for different module contexts
The tests were failing in CI because JET creates virtual modules that cause type equality checks to fail. Updated tests to use helper functions that check type names and parameters instead of direct equality. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 9b718b1 commit 25d40ad

File tree

1 file changed

+32
-16
lines changed

1 file changed

+32
-16
lines changed
Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1-
using OrdinaryDiffEqFunctionMap
2-
using OrdinaryDiffEqCore
1+
import OrdinaryDiffEqFunctionMap
2+
import OrdinaryDiffEqCore
33
using Test
44
using SciMLBase
5+
using SciMLBase: solve, init, DiscreteProblem
6+
7+
const FunctionMap = OrdinaryDiffEqFunctionMap.FunctionMap
8+
9+
# Helper functions to check algorithm properties regardless of module context
10+
is_functionmap(alg) = typeof(alg).name.name == :FunctionMap
11+
function get_scale_by_time(alg)
12+
# Access the type parameter directly since it's FunctionMap{scale_by_time}
13+
T = typeof(alg)
14+
# The parameter is stored as a type parameter
15+
return T.parameters[1]
16+
end
517

618
@testset "DiscreteProblem Default Algorithm" begin
719
# Test scalar DiscreteProblem
@@ -11,14 +23,14 @@ using SciMLBase
1123
@testset "Scalar DiscreteProblem" begin
1224
# Test solve without explicit algorithm
1325
sol = solve(prob_scalar)
14-
@test typeof(sol.alg).name.name == :FunctionMap
15-
@test sol.alg == FunctionMap()
26+
@test is_functionmap(sol.alg)
27+
@test get_scale_by_time(sol.alg) == false
1628
@test length(sol.u) > 1
1729

1830
# Test init without explicit algorithm
1931
integrator = init(prob_scalar)
20-
@test typeof(integrator.alg).name.name == :FunctionMap
21-
@test integrator.alg == FunctionMap()
32+
@test is_functionmap(integrator.alg)
33+
@test get_scale_by_time(integrator.alg) == false
2234
end
2335

2436
# Test array DiscreteProblem
@@ -31,29 +43,33 @@ using SciMLBase
3143
@testset "Array DiscreteProblem" begin
3244
# Test solve without explicit algorithm
3345
sol = solve(prob_array)
34-
@test typeof(sol.alg).name.name == :FunctionMap
35-
@test sol.alg == FunctionMap()
46+
@test is_functionmap(sol.alg)
47+
@test get_scale_by_time(sol.alg) == false
3648
@test length(sol.u) > 1
3749

3850
# Test init without explicit algorithm
3951
integrator = init(prob_array)
40-
@test typeof(integrator.alg).name.name == :FunctionMap
41-
@test integrator.alg == FunctionMap()
52+
@test is_functionmap(integrator.alg)
53+
@test get_scale_by_time(integrator.alg) == false
4254
end
4355

4456
# Test that explicit algorithm specification still works
4557
@testset "Explicit FunctionMap specification" begin
4658
sol1 = solve(prob_scalar, FunctionMap())
47-
@test sol1.alg == FunctionMap(scale_by_time=false)
59+
@test is_functionmap(sol1.alg)
60+
@test get_scale_by_time(sol1.alg) == false
4861

4962
sol2 = solve(prob_scalar, FunctionMap(scale_by_time=true), dt=0.1)
50-
@test sol2.alg == FunctionMap(scale_by_time=true)
63+
@test is_functionmap(sol2.alg)
64+
@test get_scale_by_time(sol2.alg) == true
5165

5266
integrator1 = init(prob_scalar, FunctionMap())
53-
@test integrator1.alg == FunctionMap(scale_by_time=false)
67+
@test is_functionmap(integrator1.alg)
68+
@test get_scale_by_time(integrator1.alg) == false
5469

5570
integrator2 = init(prob_scalar, FunctionMap(scale_by_time=true), dt=0.1)
56-
@test integrator2.alg == FunctionMap(scale_by_time=true)
71+
@test is_functionmap(integrator2.alg)
72+
@test get_scale_by_time(integrator2.alg) == true
5773
end
5874

5975
# Test that the default behaves correctly with different problem types
@@ -66,10 +82,10 @@ using SciMLBase
6682
prob_int = DiscreteProblem(henon_map!, [0.5, 0.5], (0, 10))
6783

6884
sol = solve(prob_int)
69-
@test typeof(sol.alg).name.name == :FunctionMap
85+
@test is_functionmap(sol.alg)
7086
@test eltype(sol.t) <: Integer
7187

7288
integrator = init(prob_int)
73-
@test typeof(integrator.alg).name.name == :FunctionMap
89+
@test is_functionmap(integrator.alg)
7490
end
7591
end

0 commit comments

Comments
 (0)