Skip to content

Commit 754fa35

Browse files
Harsh SinghHarsh Singh
authored andcommitted
fix(tests): handle both old and new Rosenbrock cache fields in resize_tests
Julia 1.10 does not support [sources] in Project.toml, so the umbrella package resolves OrdinaryDiffEqRosenbrock from the registry (old Rosenbrock23Cache). Use hasfield to handle both cache types.
1 parent 91d5cd5 commit 754fa35

1 file changed

Lines changed: 36 additions & 6 deletions

File tree

test/integrators/resize_tests.jl

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,20 @@ i = init(prob, Rosenbrock23())
7676
resize!(i, 5)
7777
@test length(i.cache.u) == 5
7878
@test length(i.cache.uprev) == 5
79-
@test all(length.(i.cache.ks) .== 5)
79+
if hasfield(typeof(i.cache), :ks)
80+
@test all(length.(i.cache.ks) .== 5)
81+
else
82+
@test length(i.cache.k₁) == 5
83+
@test length(i.cache.k₂) == 5
84+
@test length(i.cache.k₃) == 5
85+
end
8086
@test length(i.cache.du1) == 5
8187
@test length(i.cache.du2) == 5
82-
@test all(length.(i.cache.dense) .== 5)
88+
if hasfield(typeof(i.cache), :dense)
89+
@test all(length.(i.cache.dense) .== 5)
90+
else
91+
@test length(i.cache.f₁) == 5
92+
end
8393
@test length(i.cache.fsalfirst) == 5
8494
@test length(i.cache.fsallast) == 5
8595
@test length(i.cache.dT) == 5
@@ -102,10 +112,20 @@ i = init(prob, Rosenbrock23(autodiff = AutoForwardDiff(), linsolve = KrylovJL_GM
102112
resize!(i, 5)
103113
@test length(i.cache.u) == 5
104114
@test length(i.cache.uprev) == 5
105-
@test all(length.(i.cache.ks) .== 5)
115+
if hasfield(typeof(i.cache), :ks)
116+
@test all(length.(i.cache.ks) .== 5)
117+
else
118+
@test length(i.cache.k₁) == 5
119+
@test length(i.cache.k₂) == 5
120+
@test length(i.cache.k₃) == 5
121+
end
106122
@test length(i.cache.du1) == 5
107123
@test length(i.cache.du2) == 5
108-
@test all(length.(i.cache.dense) .== 5)
124+
if hasfield(typeof(i.cache), :dense)
125+
@test all(length.(i.cache.dense) .== 5)
126+
else
127+
@test length(i.cache.f₁) == 5
128+
end
109129
@test length(i.cache.fsalfirst) == 5
110130
@test length(i.cache.fsallast) == 5
111131
@test length(i.cache.dT) == 5
@@ -119,10 +139,20 @@ i = init(prob, Rosenbrock23(; autodiff = AutoFiniteDiff()))
119139
resize!(i, 5)
120140
@test length(i.cache.u) == 5
121141
@test length(i.cache.uprev) == 5
122-
@test all(length.(i.cache.ks) .== 5)
142+
if hasfield(typeof(i.cache), :ks)
143+
@test all(length.(i.cache.ks) .== 5)
144+
else
145+
@test length(i.cache.k₁) == 5
146+
@test length(i.cache.k₂) == 5
147+
@test length(i.cache.k₃) == 5
148+
end
123149
@test length(i.cache.du1) == 5
124150
@test length(i.cache.du2) == 5
125-
@test all(length.(i.cache.dense) .== 5)
151+
if hasfield(typeof(i.cache), :dense)
152+
@test all(length.(i.cache.dense) .== 5)
153+
else
154+
@test length(i.cache.f₁) == 5
155+
end
126156
@test length(i.cache.fsalfirst) == 5
127157
@test length(i.cache.fsallast) == 5
128158
@test length(i.cache.dT) == 5

0 commit comments

Comments
 (0)