Skip to content

Commit

Permalink
Updated nfinst tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
perost authored and OpenModelica-Hudson committed Feb 5, 2018
1 parent dad2e98 commit 2008d81
Show file tree
Hide file tree
Showing 11 changed files with 212 additions and 69 deletions.
35 changes: 35 additions & 0 deletions flattening/modelica/scodeinst/ConnectArrays1.mo
@@ -0,0 +1,35 @@
// name: ConnectArrays1
// keywords:
// status: correct
// cflags: -d=newInst
//
//

model ConnectArrays1
connector A
Real e;
end A;

constant Integer n=5;
A a[n];
equation
a[1].e = 1;
connect(a[1:n-1],a[2:n]);
end ConnectArrays1;

// Result:
// class ConnectArrays1
// constant Integer n = 5;
// Real a[1].e;
// Real a[2].e;
// Real a[3].e;
// Real a[4].e;
// Real a[5].e;
// equation
// a[4].e = a[5].e;
// a[4].e = a[3].e;
// a[4].e = a[2].e;
// a[4].e = a[1].e;
// a[1].e = 1.0;
// end ConnectArrays1;
// endResult
33 changes: 33 additions & 0 deletions flattening/modelica/scodeinst/ConnectArrays2.mo
@@ -0,0 +1,33 @@
// name: ConnectArrays2
// keywords:
// status: correct
// cflags: -d=newInst
//
//

model ConnectArrays2
connector InReal = input Real;
connector OutReal = output Real;
parameter Integer p = 3;
InReal x[p];
OutReal y[p+1];
equation
connect(x,y[2:p+1]);
end ConnectArrays2;

// Result:
// class ConnectArrays2
// parameter Integer p = 3;
// input Real x[1];
// input Real x[2];
// input Real x[3];
// output Real y[1];
// output Real y[2];
// output Real y[3];
// output Real y[4];
// equation
// x[1] = y[2];
// x[2] = y[3];
// x[3] = y[4];
// end ConnectArrays2;
// endResult
77 changes: 77 additions & 0 deletions flattening/modelica/scodeinst/ConnectArrays3.mo
@@ -0,0 +1,77 @@
// name: ConnectArrays3
// keywords:
// status: correct
// cflags: -d=newInst
//
//

model ConnectArrays3
model B
connector InReal = input Real;
connector OutReal = output Real;
parameter Integer p = 3;
InReal x[p];
OutReal y[p+1];
end B;

B b1[3], b2[3];
equation
connect(b1[1:3].x[1:3], b2[1:3].y[1:3]);
end ConnectArrays3;

// Result:
// class ConnectArrays3
// parameter Integer b1[1].p = 3;
// Real b1[1].x[1];
// Real b1[1].x[2];
// Real b1[1].x[3];
// Real b1[1].y[1];
// Real b1[1].y[2];
// Real b1[1].y[3];
// Real b1[1].y[4];
// parameter Integer b1[2].p = 3;
// Real b1[2].x[1];
// Real b1[2].x[2];
// Real b1[2].x[3];
// Real b1[2].y[1];
// Real b1[2].y[2];
// Real b1[2].y[3];
// Real b1[2].y[4];
// parameter Integer b1[3].p = 3;
// Real b1[3].x[1];
// Real b1[3].x[2];
// Real b1[3].x[3];
// Real b1[3].y[1];
// Real b1[3].y[2];
// Real b1[3].y[3];
// Real b1[3].y[4];
// parameter Integer b2[1].p = 3;
// Real b2[1].x[1];
// Real b2[1].x[2];
// Real b2[1].x[3];
// Real b2[1].y[1];
// Real b2[1].y[2];
// Real b2[1].y[3];
// Real b2[1].y[4];
// parameter Integer b2[2].p = 3;
// Real b2[2].x[1];
// Real b2[2].x[2];
// Real b2[2].x[3];
// Real b2[2].y[1];
// Real b2[2].y[2];
// Real b2[2].y[3];
// Real b2[2].y[4];
// parameter Integer b2[3].p = 3;
// Real b2[3].x[1];
// Real b2[3].x[2];
// Real b2[3].x[3];
// Real b2[3].y[1];
// Real b2[3].y[2];
// Real b2[3].y[3];
// Real b2[3].y[4];
// equation
// b1[1:3].x[1] = b2[1:3].y[1];
// b1[1:3].x[2] = b2[1:3].y[2];
// b1[1:3].x[3] = b2[1:3].y[3];
// end ConnectArrays3;
// endResult
11 changes: 5 additions & 6 deletions flattening/modelica/scodeinst/Makefile
Expand Up @@ -114,6 +114,9 @@ Connect2.mo \
Connect4.mo \
Connect5.mo \
ConnectAlgorithm.mo \
ConnectArrays1.mo \
ConnectArrays2.mo \
ConnectArrays3.mo \
ConnectDiffOrder1.mo \
ConnectDiffOrder2.mo \
ConnectInitial.mo \
Expand Down Expand Up @@ -204,6 +207,8 @@ eq1.mo \
eq2.mo \
eq3.mo \
eq4.mo \
eq5.mo \
eq6.mo \
eq7.mo \
eq8.mo \
eq10.mo \
Expand Down Expand Up @@ -557,19 +562,14 @@ DuplicateElementsValid2.mo \
DuplicateElementsCond1.mo \
ceval4.mo \
cond3.mo \
conn11.mo \
conn12.mo \
conn13.mo \
conn14.mo \
conn6.mo \
conn7.mo \
conn8.mo \
conn9.mo \
conngraph1.mo \
conngraph2.mo \
enum6.mo \
eq5.mo \
eq6.mo \
expconn1.mo \
expconn2.mo \
expconn3.mo \
Expand All @@ -581,7 +581,6 @@ func1.mo \
FuncBuiltinCardinality.mo \
FuncBuiltinEnumTypeName.mo \
FuncBuiltinReduction.mo \
function1.mo \
FunctionRecordArg1.mo \
ImportConflict1.mo \
ImportShadowing1.mo \
Expand Down
23 changes: 23 additions & 0 deletions flattening/modelica/scodeinst/Subscript2.mo
@@ -0,0 +1,23 @@
// name: Subscript2
// status: correct
// cflags: -d=newInst
//
//

model Subscript2
Real x[3] = {1, 2, 3};
Real y[2] = x[2:3];
end Subscript2;

// Result:
// class Subscript2
// Real x[1];
// Real x[2];
// Real x[3];
// Real y[1];
// Real y[2];
// equation
// x = {1.0, 2.0, 3.0};
// y = x[2:3];
// end Subscript2;
// endResult
29 changes: 29 additions & 0 deletions flattening/modelica/scodeinst/Subscript3.mo
@@ -0,0 +1,29 @@
// name: Subscript3
// status: correct
// cflags: -d=newInst
//
//

model Subscript3
Real x[3, 2] = {{1, 2}, {3, 4}, {5, 6}};
Real y[2, 1];
equation
y = x[2:3, 1:1];
end Subscript3;

// Result:
// class Subscript3
// Real x[1,1];
// Real x[1,2];
// Real x[2,1];
// Real x[2,2];
// Real x[3,1];
// Real x[3,2];
// Real y[1,1];
// Real y[2,1];
// equation
// x = {{1.0, 2.0}, {3.0, 4.0}, {5.0, 6.0}};
// y[1,1] = x[2,1];
// y[2,1] = x[3,1];
// end Subscript3;
// endResult
19 changes: 0 additions & 19 deletions flattening/modelica/scodeinst/conn11.mo

This file was deleted.

17 changes: 0 additions & 17 deletions flattening/modelica/scodeinst/conn6.mo

This file was deleted.

22 changes: 0 additions & 22 deletions flattening/modelica/scodeinst/conn7.mo

This file was deleted.

8 changes: 7 additions & 1 deletion flattening/modelica/scodeinst/eq5.mo
Expand Up @@ -28,14 +28,20 @@ end B;

// Result:
// class B
// constant Integer a[1].j = 1;
// constant Integer a[1].m.i = {1, 2, 3};
// constant Integer a[2].j = 2;
// constant Integer a[2].m.i = {1, 2, 3};
// constant Integer a[3].j = 3;
// constant Integer a[3].m.i = {1, 2, 3};
// Real x[1];
// Real x[2];
// Real x[3];
// Real y[1];
// Real y[2];
// Real y[3];
// equation
// x[1] = y[1];
// x[1] = 1.0 * y[1];
// x[2] = 2.0 * y[2];
// x[3] = 3.0 * y[3];
// end B;
Expand Down
7 changes: 3 additions & 4 deletions flattening/modelica/scodeinst/eq6.mo
Expand Up @@ -20,13 +20,12 @@ end B;

// Result:
// class B
// constant Integer P.i = 2;
// Real a[1].x;
// Real a[2].x;
// Real a[3].x;
// equation
// a[1].x = /*Real*/(P.i);
// a[2].x = /*Real*/(P.i);
// a[3].x = /*Real*/(P.i);
// a[1].x = 2.0;
// a[2].x = 2.0;
// a[3].x = 2.0;
// end B;
// endResult

0 comments on commit 2008d81

Please sign in to comment.