From ed71a6baacfc9681afc8c1ce4e1d1ab28c28681a Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Fri, 20 Sep 2024 13:04:26 +0530 Subject: [PATCH] test: test `@mtkmodel` array variables, default namespacing --- test/model_parsing.jl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/model_parsing.jl b/test/model_parsing.jl index 40fb0a13f2..704971878c 100644 --- a/test/model_parsing.jl +++ b/test/model_parsing.jl @@ -3,6 +3,7 @@ using ModelingToolkit: get_connector_type, get_defaults, get_gui_metadata, get_systems, get_ps, getdefault, getname, readable_code, scalarize, symtype, VariableDescription, RegularConnector, get_unit +using SymbolicIndexingInterface using URIs: URI using Distributions using DynamicQuantities, OrdinaryDiffEq @@ -876,3 +877,26 @@ end end), false) end + +@testset "Array parameters and subcomponent defaults" begin + @mtkmodel Foo begin + @parameters begin + p[1:3] + end + end + @mtkmodel Bar begin + @parameters begin + q[1:3] + end + @components begin + foo = Foo(p = q) + end + end + @named model = Bar() + model = complete(model) + # non-scalarized versions are parameters + @test is_parameter(model, model.q) + @test is_parameter(model, model.foo.p) + # default is correctly (not) namespaced + @test ModelingToolkit.defaults(model)[model.foo.p] == model.q +end