Skip to content

Commit

Permalink
test: conditionally define component array
Browse files Browse the repository at this point in the history
  • Loading branch information
ven-k committed Mar 4, 2024
1 parent a4a79ce commit 763f6df
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/model_parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,30 @@ end
@test getdefault(component.comprehension_2.sc) == 2
@test getdefault(component.written_out_for_1.sc) == 2
@test getdefault(component.written_out_for_2.sc) == 3

@mtkmodel ConditionalComponent begin
@structural_parameters begin
N = 2
end
@components begin
if N == 2
if_comprehension = [SubComponent(sc = i) for i in 1:N]
elseif N == 3
elseif_comprehension = [SubComponent(sc = i) for i in 1:N]
else
else_comprehension = [SubComponent(sc = i) for i in 1:N]
end
end
end

@named if_component = ConditionalComponent()
@test nameof.(get_systems(if_component)) == [:if_comprehension_1, :if_comprehension_2]

@named elseif_component = ConditionalComponent(; N = 3)
@test nameof.(get_systems(elseif_component)) == [:elseif_comprehension_1, :elseif_comprehension_2, :elseif_comprehension_3]

@named else_component = ConditionalComponent(; N = 4)
@test nameof.(get_systems(else_component)) == [:else_comprehension_1, :else_comprehension_2, :else_comprehension_3, :else_comprehension_4]
end

@testset "Parent module of Models" begin
Expand Down

0 comments on commit 763f6df

Please sign in to comment.