Skip to content

Commit 83f572c

Browse files
committed
refactor tests
1 parent 12cf512 commit 83f572c

File tree

2 files changed

+15
-21
lines changed

2 files changed

+15
-21
lines changed

test/odesystem.jl

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,18 +1673,3 @@ end
16731673
prob = ODEProblem{false}(lowered_dae_sys; u0_constructor = x -> SVector(x...))
16741674
@test prob.u0 isa SVector
16751675
end
1676-
1677-
@testset "input map validation" begin
1678-
import ModelingToolkit: InvalidKeyError
1679-
@variables x(t) y(t) z(t)
1680-
@parameters a b c d
1681-
eqs = [D(x) ~ x*a, D(y) ~ y*c, D(z) ~ b + d]
1682-
@mtkbuild sys = ODESystem(eqs, t)
1683-
pmap = [a => 1, b => 2, c => 3, d => 4, "b" => 2]
1684-
u0map = [x => 1, y => 2, z => 3]
1685-
@test_throws InvalidKeyError ODEProblem(sys, u0map, (0., 1.), pmap)
1686-
1687-
pmap = [a => 1, b => 2, c => 3, d => 4]
1688-
u0map = [x => 1, y => 2, z => 3, :0 => 3]
1689-
@test_throws InvalidKeyError ODEProblem(sys, u0map, (0., 1.), pmap)
1690-
end

test/problem_validation.jl

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ using ModelingToolkit
22
using ModelingToolkit: t_nounits as t, D_nounits as D
33

44
@testset "Input map validation" begin
5+
import ModelingToolkit: InvalidKeyError, MissingParametersError
56
@variables X(t)
67
@parameters p d
78
eqs = [D(X) ~ p - d*X]
@@ -10,16 +11,24 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
1011
p = "I accidentally renamed p"
1112
u0 = [X => 1.0]
1213
ps = [p => 1.0, d => 0.5]
13-
@test_throws ModelingToolkit.BadKeyError oprob = ODEProblem(osys, u0, (0.0, 1.0), ps)
14+
@test_throws MissingParametersError oprob = ODEProblem(osys, u0, (0.0, 1.0), ps)
1415

1516
@parameters p d
1617
ps = [p => 1.0, d => 0.5, "Random stuff" => 3.0]
17-
@test_throws ModelingToolkit.BadKeyError oprob = ODEProblem(osys, u0, (0.0, 1.0), ps)
18+
@test_throws InvalidKeyError oprob = ODEProblem(osys, u0, (0.0, 1.0), ps)
1819

1920
u0 = [:X => 1.0, "random" => 3.0]
20-
@test_throws ModelingToolkit.BadKeyError oprob = ODEProblem(osys, u0, (0.0, 1.0), ps)
21+
@test_throws InvalidKeyError oprob = ODEProblem(osys, u0, (0.0, 1.0), ps)
2122

22-
@parameters k
23-
ps = [p => 1., d => 0.5, k => 3.]
24-
@test_throws ModelingToolkit.BadKeyError oprob = ODEProblem(osys, u0, (0.0, 1.0), ps)
23+
@variables x(t) y(t) z(t)
24+
@parameters a b c d
25+
eqs = [D(x) ~ x*a, D(y) ~ y*c, D(z) ~ b + d]
26+
@mtkbuild sys = ODESystem(eqs, t)
27+
pmap = [a => 1, b => 2, c => 3, d => 4, "b" => 2]
28+
u0map = [x => 1, y => 2, z => 3]
29+
@test_throws InvalidKeyError ODEProblem(sys, u0map, (0., 1.), pmap)
30+
31+
pmap = [a => 1, b => 2, c => 3, d => 4]
32+
u0map = [x => 1, y => 2, z => 3, :0 => 3]
33+
@test_throws InvalidKeyError ODEProblem(sys, u0map, (0., 1.), pmap)
2534
end

0 commit comments

Comments
 (0)