Skip to content

Commit

Permalink
Update nfinst tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
perost authored and OpenModelica-Hudson committed Nov 15, 2017
1 parent 2bdb8a0 commit 4d95b57
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 0 deletions.
49 changes: 49 additions & 0 deletions flattening/modelica/scodeinst/ForConnect1.mo
@@ -0,0 +1,49 @@
// name: ForConnect1
// keywords:
// status: correct
// cflags: -d=newInst
//
//

connector C
Real e;
flow Real f;
end C;

model ForConnect1
C c1[3], c2[3];
equation
for i in 1:3 loop
connect(c1[i], c2[i]);
end for;
end ForConnect1;

// Result:
// class ForConnect1
// Real c1[1].e;
// Real c1[1].f;
// Real c1[2].e;
// Real c1[2].f;
// Real c1[3].e;
// Real c1[3].f;
// Real c2[1].e;
// Real c2[1].f;
// Real c2[2].e;
// Real c2[2].f;
// Real c2[3].e;
// Real c2[3].f;
// equation
// c1[1].e = c2[1].e;
// (-c1[1].f) + (-c2[1].f) = 0.0;
// c1[2].e = c2[2].e;
// (-c1[2].f) + (-c2[2].f) = 0.0;
// c1[3].e = c2[3].e;
// (-c1[3].f) + (-c2[3].f) = 0.0;
// c1[1].f = 0.0;
// c1[2].f = 0.0;
// c1[3].f = 0.0;
// c2[1].f = 0.0;
// c2[2].f = 0.0;
// c2[3].f = 0.0;
// end ForConnect1;
// endResult
35 changes: 35 additions & 0 deletions flattening/modelica/scodeinst/IfConnect1.mo
@@ -0,0 +1,35 @@
// name: IfConnect1
// keywords:
// status: correct
// cflags: -d=newInst
//
//

connector C
Real e;
flow Real f;
end C;

model IfConnect1
parameter Boolean b = true;
C c1, c2;
equation
if b then
connect(c1, c2);
end if;
end IfConnect1;

// Result:
// class IfConnect1
// parameter Boolean b = true;
// Real c1.e;
// Real c1.f;
// Real c2.e;
// Real c2.f;
// equation
// c1.e = c2.e;
// (-c1.f) + (-c2.f) = 0.0;
// c1.f = 0.0;
// c2.f = 0.0;
// end IfConnect1;
// endResult
33 changes: 33 additions & 0 deletions flattening/modelica/scodeinst/IfConnect2.mo
@@ -0,0 +1,33 @@
// name: IfConnect2
// keywords:
// status: correct
// cflags: -d=newInst
//
//

connector C
Real e;
flow Real f;
end C;

model IfConnect2
parameter Boolean b = false;
C c1, c2;
equation
if b then
connect(c1, c2);
end if;
end IfConnect2;

// Result:
// class IfConnect2
// parameter Boolean b = false;
// Real c1.e;
// Real c1.f;
// Real c2.e;
// Real c2.f;
// equation
// c1.f = 0.0;
// c2.f = 0.0;
// end IfConnect2;
// endResult
30 changes: 30 additions & 0 deletions flattening/modelica/scodeinst/IfConnect3.mo
@@ -0,0 +1,30 @@
// name: IfConnect3
// keywords:
// status: incorrect
// cflags: -d=newInst
//
//

connector C
Real e;
flow Real f;
end C;

model IfConnect3
Boolean b = true;
C c1, c2;
equation
if b then
connect(c1, c2);
end if;
end IfConnect3;

// Result:
// Error processing file: IfConnect3.mo
// [flattening/modelica/scodeinst/IfConnect3.mo:18:5-18:20:writable] Error: connect may not be used inside if-equations with non-parametric conditions (found connect(c1, c2)).
//
// # Error encountered! Exiting...
// # Please check the error message and the flags.
//
// Execution failed!
// endResult
4 changes: 4 additions & 0 deletions flattening/modelica/scodeinst/Makefile
Expand Up @@ -173,6 +173,7 @@ ExtendsVisibility2.mo \
ExtendsVisibility3.mo \
ExtendsVisibility4.mo \
ExtendsVisibility5.mo \
ForConnect1.mo \
ForEquation1.mo \
ForEquation2.mo \
ForEquation3.mo \
Expand Down Expand Up @@ -235,6 +236,9 @@ FunctionMultiOutput2.mo \
FunctionMultiOutput3.mo \
FunctionNoOutput1.mo \
FunctionStreamPrefix.mo \
IfConnect1.mo \
IfConnect2.mo \
IfConnect3.mo \
IfEquation1.mo \
IfEquation2.mo \
IfEquation3.mo \
Expand Down

0 comments on commit 4d95b57

Please sign in to comment.