@@ -12,32 +12,39 @@ Currently, Rosenbrock solvers are allocating and marked with @test_broken.
1212@testset " Rosenbrock Allocation Tests" begin
1313 # Test problem - use a simple linear problem for stiff solvers
1414 linear_prob = ODEProblem ((u, p, t) -> - u, 1.0 , (0.0 , 1.0 ))
15-
15+
1616 # Vector problem
1717 function simple_system! (du, u, p, t)
1818 du[1 ] = - 0.5 * u[1 ]
1919 du[2 ] = - 1.5 * u[2 ]
2020 end
2121 vector_prob = ODEProblem (simple_system!, [1.0 , 1.0 ], (0.0 , 1.0 ))
22-
23- # Test all exported Rosenbrock solvers for allocation-free behavior
22+
23+ # Test all exported Rosenbrock solvers for allocation-free behavior
2424 rosenbrock_solvers = [Rosenbrock23 (), Rosenbrock32 (), RosShamp4 (), Veldd4 (), Velds4 (), GRK4T (), GRK4A (),
2525 Rodas3 (), Rodas23W (), Rodas3P (), Rodas4 (), Rodas42 (), Rodas4P (), Rodas4P2 (), Rodas5 (),
2626 Rodas5P (), Rodas5Pe (), Rodas5Pr (), Rodas6P ()]
27-
27+
2828 @testset " Rosenbrock Solver Allocation Analysis" begin
2929 for solver in rosenbrock_solvers
3030 @testset " $(typeof (solver)) allocation check" begin
3131 integrator = init (linear_prob, solver, dt= 0.1 , save_everystep= false , abstol= 1e-6 , reltol= 1e-6 )
3232 step! (integrator) # Setup step may allocate
33-
33+
3434 # Use AllocCheck for accurate allocation detection
3535 allocs = check_allocs (step!, (typeof (integrator),))
36-
36+
3737 # These solvers should be allocation-free, but mark as broken for now
3838 # to verify with AllocCheck (more accurate than @allocated)
3939 @test_broken length (allocs) == 0
40-
40+
41+ # However, we don't want to allow any dynamic dispatch from this module
42+ @test count (
43+ t -> t isa AllocCheck. DynamicDispatch &&
44+ any (s -> contains (string (s. file), " Rosenbrock" ), t. backtrace),
45+ allocs
46+ ) == 0
47+
4148 if length (allocs) > 0
4249 println (" AllocCheck found $(length (allocs)) allocation sites in $(typeof (solver)) step!:" )
4350 for (i, alloc) in enumerate (allocs[1 : min (3 , end )]) # Show first 3
0 commit comments