Skip to content

Commit 2008d81

Browse files
perostOpenModelica-Hudson
authored andcommitted
Updated nfinst tests.
Belonging to [master]: - OpenModelica/OMCompiler#2160 - OpenModelica/OpenModelica-testsuite#841
1 parent dad2e98 commit 2008d81

File tree

11 files changed

+212
-69
lines changed

11 files changed

+212
-69
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// name: ConnectArrays1
2+
// keywords:
3+
// status: correct
4+
// cflags: -d=newInst
5+
//
6+
//
7+
8+
model ConnectArrays1
9+
connector A
10+
Real e;
11+
end A;
12+
13+
constant Integer n=5;
14+
A a[n];
15+
equation
16+
a[1].e = 1;
17+
connect(a[1:n-1],a[2:n]);
18+
end ConnectArrays1;
19+
20+
// Result:
21+
// class ConnectArrays1
22+
// constant Integer n = 5;
23+
// Real a[1].e;
24+
// Real a[2].e;
25+
// Real a[3].e;
26+
// Real a[4].e;
27+
// Real a[5].e;
28+
// equation
29+
// a[4].e = a[5].e;
30+
// a[4].e = a[3].e;
31+
// a[4].e = a[2].e;
32+
// a[4].e = a[1].e;
33+
// a[1].e = 1.0;
34+
// end ConnectArrays1;
35+
// endResult
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// name: ConnectArrays2
2+
// keywords:
3+
// status: correct
4+
// cflags: -d=newInst
5+
//
6+
//
7+
8+
model ConnectArrays2
9+
connector InReal = input Real;
10+
connector OutReal = output Real;
11+
parameter Integer p = 3;
12+
InReal x[p];
13+
OutReal y[p+1];
14+
equation
15+
connect(x,y[2:p+1]);
16+
end ConnectArrays2;
17+
18+
// Result:
19+
// class ConnectArrays2
20+
// parameter Integer p = 3;
21+
// input Real x[1];
22+
// input Real x[2];
23+
// input Real x[3];
24+
// output Real y[1];
25+
// output Real y[2];
26+
// output Real y[3];
27+
// output Real y[4];
28+
// equation
29+
// x[1] = y[2];
30+
// x[2] = y[3];
31+
// x[3] = y[4];
32+
// end ConnectArrays2;
33+
// endResult
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// name: ConnectArrays3
2+
// keywords:
3+
// status: correct
4+
// cflags: -d=newInst
5+
//
6+
//
7+
8+
model ConnectArrays3
9+
model B
10+
connector InReal = input Real;
11+
connector OutReal = output Real;
12+
parameter Integer p = 3;
13+
InReal x[p];
14+
OutReal y[p+1];
15+
end B;
16+
17+
B b1[3], b2[3];
18+
equation
19+
connect(b1[1:3].x[1:3], b2[1:3].y[1:3]);
20+
end ConnectArrays3;
21+
22+
// Result:
23+
// class ConnectArrays3
24+
// parameter Integer b1[1].p = 3;
25+
// Real b1[1].x[1];
26+
// Real b1[1].x[2];
27+
// Real b1[1].x[3];
28+
// Real b1[1].y[1];
29+
// Real b1[1].y[2];
30+
// Real b1[1].y[3];
31+
// Real b1[1].y[4];
32+
// parameter Integer b1[2].p = 3;
33+
// Real b1[2].x[1];
34+
// Real b1[2].x[2];
35+
// Real b1[2].x[3];
36+
// Real b1[2].y[1];
37+
// Real b1[2].y[2];
38+
// Real b1[2].y[3];
39+
// Real b1[2].y[4];
40+
// parameter Integer b1[3].p = 3;
41+
// Real b1[3].x[1];
42+
// Real b1[3].x[2];
43+
// Real b1[3].x[3];
44+
// Real b1[3].y[1];
45+
// Real b1[3].y[2];
46+
// Real b1[3].y[3];
47+
// Real b1[3].y[4];
48+
// parameter Integer b2[1].p = 3;
49+
// Real b2[1].x[1];
50+
// Real b2[1].x[2];
51+
// Real b2[1].x[3];
52+
// Real b2[1].y[1];
53+
// Real b2[1].y[2];
54+
// Real b2[1].y[3];
55+
// Real b2[1].y[4];
56+
// parameter Integer b2[2].p = 3;
57+
// Real b2[2].x[1];
58+
// Real b2[2].x[2];
59+
// Real b2[2].x[3];
60+
// Real b2[2].y[1];
61+
// Real b2[2].y[2];
62+
// Real b2[2].y[3];
63+
// Real b2[2].y[4];
64+
// parameter Integer b2[3].p = 3;
65+
// Real b2[3].x[1];
66+
// Real b2[3].x[2];
67+
// Real b2[3].x[3];
68+
// Real b2[3].y[1];
69+
// Real b2[3].y[2];
70+
// Real b2[3].y[3];
71+
// Real b2[3].y[4];
72+
// equation
73+
// b1[1:3].x[1] = b2[1:3].y[1];
74+
// b1[1:3].x[2] = b2[1:3].y[2];
75+
// b1[1:3].x[3] = b2[1:3].y[3];
76+
// end ConnectArrays3;
77+
// endResult

flattening/modelica/scodeinst/Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ Connect2.mo \
114114
Connect4.mo \
115115
Connect5.mo \
116116
ConnectAlgorithm.mo \
117+
ConnectArrays1.mo \
118+
ConnectArrays2.mo \
119+
ConnectArrays3.mo \
117120
ConnectDiffOrder1.mo \
118121
ConnectDiffOrder2.mo \
119122
ConnectInitial.mo \
@@ -204,6 +207,8 @@ eq1.mo \
204207
eq2.mo \
205208
eq3.mo \
206209
eq4.mo \
210+
eq5.mo \
211+
eq6.mo \
207212
eq7.mo \
208213
eq8.mo \
209214
eq10.mo \
@@ -557,19 +562,14 @@ DuplicateElementsValid2.mo \
557562
DuplicateElementsCond1.mo \
558563
ceval4.mo \
559564
cond3.mo \
560-
conn11.mo \
561565
conn12.mo \
562566
conn13.mo \
563567
conn14.mo \
564-
conn6.mo \
565-
conn7.mo \
566568
conn8.mo \
567569
conn9.mo \
568570
conngraph1.mo \
569571
conngraph2.mo \
570572
enum6.mo \
571-
eq5.mo \
572-
eq6.mo \
573573
expconn1.mo \
574574
expconn2.mo \
575575
expconn3.mo \
@@ -581,7 +581,6 @@ func1.mo \
581581
FuncBuiltinCardinality.mo \
582582
FuncBuiltinEnumTypeName.mo \
583583
FuncBuiltinReduction.mo \
584-
function1.mo \
585584
FunctionRecordArg1.mo \
586585
ImportConflict1.mo \
587586
ImportShadowing1.mo \
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// name: Subscript2
2+
// status: correct
3+
// cflags: -d=newInst
4+
//
5+
//
6+
7+
model Subscript2
8+
Real x[3] = {1, 2, 3};
9+
Real y[2] = x[2:3];
10+
end Subscript2;
11+
12+
// Result:
13+
// class Subscript2
14+
// Real x[1];
15+
// Real x[2];
16+
// Real x[3];
17+
// Real y[1];
18+
// Real y[2];
19+
// equation
20+
// x = {1.0, 2.0, 3.0};
21+
// y = x[2:3];
22+
// end Subscript2;
23+
// endResult
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// name: Subscript3
2+
// status: correct
3+
// cflags: -d=newInst
4+
//
5+
//
6+
7+
model Subscript3
8+
Real x[3, 2] = {{1, 2}, {3, 4}, {5, 6}};
9+
Real y[2, 1];
10+
equation
11+
y = x[2:3, 1:1];
12+
end Subscript3;
13+
14+
// Result:
15+
// class Subscript3
16+
// Real x[1,1];
17+
// Real x[1,2];
18+
// Real x[2,1];
19+
// Real x[2,2];
20+
// Real x[3,1];
21+
// Real x[3,2];
22+
// Real y[1,1];
23+
// Real y[2,1];
24+
// equation
25+
// x = {{1.0, 2.0}, {3.0, 4.0}, {5.0, 6.0}};
26+
// y[1,1] = x[2,1];
27+
// y[2,1] = x[3,1];
28+
// end Subscript3;
29+
// endResult

flattening/modelica/scodeinst/conn11.mo

Lines changed: 0 additions & 19 deletions
This file was deleted.

flattening/modelica/scodeinst/conn6.mo

Lines changed: 0 additions & 17 deletions
This file was deleted.

flattening/modelica/scodeinst/conn7.mo

Lines changed: 0 additions & 22 deletions
This file was deleted.

flattening/modelica/scodeinst/eq5.mo

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,20 @@ end B;
2828

2929
// Result:
3030
// class B
31+
// constant Integer a[1].j = 1;
32+
// constant Integer a[1].m.i = {1, 2, 3};
33+
// constant Integer a[2].j = 2;
34+
// constant Integer a[2].m.i = {1, 2, 3};
35+
// constant Integer a[3].j = 3;
36+
// constant Integer a[3].m.i = {1, 2, 3};
3137
// Real x[1];
3238
// Real x[2];
3339
// Real x[3];
3440
// Real y[1];
3541
// Real y[2];
3642
// Real y[3];
3743
// equation
38-
// x[1] = y[1];
44+
// x[1] = 1.0 * y[1];
3945
// x[2] = 2.0 * y[2];
4046
// x[3] = 3.0 * y[3];
4147
// end B;

0 commit comments

Comments
 (0)