File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ using SymbolicUtils: issym
99using  ForwardDiff
1010using  ModelingToolkit:  value
1111using  ModelingToolkit:  t_nounits as t, D_nounits as D
12+ using  Symbolics:  unwrap
1213
1314#  Define some variables
1415@parameters  σ ρ β
@@ -1732,3 +1733,26 @@ end
17321733    @test  obsfn_expr_oop isa  Expr
17331734    @test  obsfn_expr_iip isa  Expr
17341735end 
1736+ 
1737+ @testset  " `@named` always wraps in `ParentScope`"   begin 
1738+     function  SysA (; name, var1)
1739+         @variables  x (t)
1740+         scope =  ModelingToolkit. getmetadata (unwrap (var1), ModelingToolkit. SymScope, nothing )
1741+         @test  scope isa  ParentScope
1742+         @test  scope. parent isa  ParentScope
1743+         @test  scope. parent. parent isa  LocalScope
1744+         return  ODESystem (D (x) ~  var1, t; name)
1745+     end 
1746+     function  SysB (; name, var1)
1747+         @variables  x (t)
1748+         @named  subsys =  SysA (; var1)
1749+         return  ODESystem (D (x) ~  x, t; systems =  [subsys], name)
1750+     end 
1751+     function  SysC (; name)
1752+         @variables  x (t)
1753+         @named  subsys =  SysB (; var1 =  x)
1754+         return  ODESystem (D (x) ~  x, t; systems =  [subsys], name)
1755+     end 
1756+     @mtkbuild  sys =  SysC ()
1757+     @test  length (unknowns (sys)) ==  3 
1758+ end 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments