Skip to content

Commit 8b0733a

Browse files
committed
Add tests for new functionality
1 parent a347d10 commit 8b0733a

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

test/dq_units.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,20 @@ maj2 = MassActionJump(γ, [I => 1], [I => -1, R => 1])
157157
maj1 = MassActionJump(2.0, [0 => 1], [S => 1])
158158
maj2 = MassActionJump(γ, [S => 1], [S => -1])
159159
@named js4 = JumpSystem([maj1, maj2], ModelingToolkit.t_nounits, [S], [β, γ])
160+
161+
@mtkmodel ParamTest begin
162+
@parameters begin
163+
a, [unit=u"m"]
164+
end
165+
@variables begin
166+
b(t), [unit=u"kg"]
167+
end
168+
end
169+
170+
@named sys = ParamTest()
171+
172+
@named sys = ParamTest(a=3.0u"cm")
173+
@test ModelingToolkit.getdefault(sys.a) 0.03
174+
175+
@test_throws ErrorException ParamTest(;name=:t, a=1.0)
176+
@test_throws ErrorException ParamTest(;name=:t, a=1.0u"s")

test/units.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,20 @@ maj2 = MassActionJump(γ, [I => 1], [I => -1, R => 1])
192192
maj1 = MassActionJump(2.0, [0 => 1], [S => 1])
193193
maj2 = MassActionJump(γ, [S => 1], [S => -1])
194194
@named js4 = JumpSystem([maj1, maj2], t, [S], [β, γ])
195+
196+
@mtkmodel ParamTest begin
197+
@parameters begin
198+
a, [unit=u"m"]
199+
end
200+
@variables begin
201+
b(t), [unit=u"kg"]
202+
end
203+
end
204+
205+
@named sys = ParamTest()
206+
207+
@named sys = ParamTest(a=3.0u"cm")
208+
@test ModelingToolkit.getdefault(sys.a) 0.03
209+
210+
@test_throws ErrorException ParamTest(;name=:t, a=1.0)
211+
@test_throws ErrorException ParamTest(;name=:t, a=1.0u"s")

0 commit comments

Comments
 (0)