Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
YingboMa committed Oct 8, 2023
1 parent c3c030e commit cd0f04a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test/model_parsing.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using ModelingToolkit, Test
using ModelingToolkit: get_gui_metadata,
VariableDescription, getdefault, RegularConnector, get_ps
VariableDescription, getdefault, RegularConnector, get_ps, getname
using URIs: URI
using Distributions
using Unitful
Expand Down Expand Up @@ -146,7 +146,11 @@ l15 0" stroke="black" stroke-width="1" stroke-linejoin="bevel" fill="none"></pat
C_val = 20
R_val = 20
res__R = 100
@named rc = RC(; C_val, R_val, resistor.R = res__R)
@mtkbuild rc = RC(; C_val, R_val, resistor.R = res__R)
resistor = getproperty(rc, :resistor; namespace = false)
@test getname(rc.resistor) === getname(resistor)
@test getname(rc.resistor.R) === getname(resistor.R)
@test getname(rc.resistor.v) === getname(resistor.v)
# Test that `resistor.R` overrides `R_val` in the argument.
@test getdefault(rc.resistor.R) == res__R != R_val
# Test that `C_val` passed via argument is set as default of C.
Expand All @@ -166,7 +170,7 @@ l15 0" stroke="black" stroke-width="1" stroke-linejoin="bevel" fill="none"></pat
@test ModelingToolkit.get_gui_metadata(rc.resistor.p).layout == Pin.structure[:icon] ==
URI("file:///" * abspath(ENV["MTK_ICONS_DIR"], "pin.png"))

@test length(equations(structural_simplify(rc))) == 1
@test length(equations(rc)) == 1
end

@testset "Parameters and Structural parameters in various modes" begin
Expand Down

0 comments on commit cd0f04a

Please sign in to comment.