Skip to content

Commit ed71a6b

Browse files
test: test @mtkmodel array variables, default namespacing
1 parent ac88d49 commit ed71a6b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/model_parsing.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ using ModelingToolkit: get_connector_type, get_defaults, get_gui_metadata,
33
get_systems, get_ps, getdefault, getname, readable_code,
44
scalarize, symtype, VariableDescription, RegularConnector,
55
get_unit
6+
using SymbolicIndexingInterface
67
using URIs: URI
78
using Distributions
89
using DynamicQuantities, OrdinaryDiffEq
@@ -876,3 +877,26 @@ end
876877
end),
877878
false)
878879
end
880+
881+
@testset "Array parameters and subcomponent defaults" begin
882+
@mtkmodel Foo begin
883+
@parameters begin
884+
p[1:3]
885+
end
886+
end
887+
@mtkmodel Bar begin
888+
@parameters begin
889+
q[1:3]
890+
end
891+
@components begin
892+
foo = Foo(p = q)
893+
end
894+
end
895+
@named model = Bar()
896+
model = complete(model)
897+
# non-scalarized versions are parameters
898+
@test is_parameter(model, model.q)
899+
@test is_parameter(model, model.foo.p)
900+
# default is correctly (not) namespaced
901+
@test ModelingToolkit.defaults(model)[model.foo.p] == model.q
902+
end

0 commit comments

Comments
 (0)