@@ -356,17 +356,82 @@ end
356356 end
357357 end
358358
359- @mtkbuild a1 = A (eq_flag = 1 )
359+ @named a1 = A (eq_flag = 1 )
360+ a1 = complete (a1)
360361 @test getdefault (a1. c. val) == 1
361362 @test all ([a1. eq ~ 0 , a1. eq ~ 1 ] .∈ [equations (a1)])
363+ a1 = complete (a1)
362364
363- @mtkbuild a2 = A (c_flag = 2 )
365+ @named a2 = A (c_flag = 2 )
366+ a2 = complete (a2)
364367 @test getdefault (a2. c. val) == 2
365368 @test all ([a2. eq ~ 0 , a2. eq ~ 2 ] .∈ [equations (a2)])
366369
367370 @test all (:comp0 .∈ [nameof .(a1. systems), nameof .(a2. systems)])
368371
369- @mtkbuild a3 = A (eq_flag = false , c_flag = 3 )
372+ @named a3 = A (eq_flag = false , c_flag = 3 )
373+ a3 = complete (a3)
370374 @test getdefault (a3. c. val) == 3
371375 @test all ([a3. eq ~ 0 , a3. eq ~ 3 ] .∈ [equations (a3)])
376+
377+ @mtkmodel B begin
378+ @structural_parameters begin
379+ condition = 2
380+ end
381+ @parameters begin
382+ a0
383+ a1
384+ a2
385+ a3
386+ end
387+
388+ @components begin
389+ c0 = C ()
390+ end
391+
392+ @equations begin
393+ a0 ~ 0
394+ end
395+
396+ if condition == 1
397+ @equations begin
398+ a1 ~ 0
399+ end
400+ @components begin
401+ c1 = C ()
402+ end
403+ elseif condition == 2
404+ @equations begin
405+ a2 ~ 0
406+ end
407+ @components begin
408+ c2 = C ()
409+ end
410+ else
411+ @equations begin
412+ a3 ~ 0
413+ end
414+ @components begin
415+ c3 = C ()
416+ end
417+ end
418+ end
419+
420+ @named b1 = B (condition = 1 )
421+ b1 = complete (b1)
422+ @named b2 = B (condition = 2 )
423+ b2 = complete (b2)
424+ @named b3 = B (condition = 10 )
425+ b3 = complete (b3)
426+
427+ @test nameof .(b1. systems) == [:c1 , :c0 ]
428+ @test nameof .(b2. systems) == [:c2 , :c0 ]
429+ @test nameof .(b3. systems) == [:c3 , :c0 ]
430+
431+ @test Equation[b1. a1 ~ 0
432+ b1. a0 ~ 0 ] == equations (b1)
433+ @test Equation[b2. a2 ~ 0
434+ b1. a0 ~ 0 ] == equations (b2)
435+ @test Equation[b3. a3 ~ 0
436+ b1. a0 ~ 0 ] == equations (b3)
372437end
0 commit comments