Skip to content

Commit 72fc673

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Add subscripting tests.
Belonging to [master]: - OpenModelica/OMCompiler#2609 - OpenModelica/OpenModelica-testsuite#1015
1 parent a40caf2 commit 72fc673

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

flattening/modelica/scodeinst/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,8 @@ Subscript1.mo \
692692
Subscript2.mo \
693693
Subscript3.mo \
694694
Subscript4.mo \
695+
Subscript5.mo \
696+
Subscript6.mo \
695697
SubscriptCevalIndex1.mo \
696698
SubscriptCevalIndexRange1.mo \
697699
SubscriptCevalSlice1.mo \
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// name: Subscript5
2+
// status: correct
3+
// cflags: -d=newInst
4+
//
5+
// Checks that partially subscripted crefs are padded with :.
6+
//
7+
8+
function f
9+
input Real x[:, :];
10+
input Real y[:, :];
11+
output Real z;
12+
algorithm
13+
z := x[1] * y[2];
14+
end f;
15+
16+
model Subscript5
17+
Real x[3, 3] = {{time, 1, 2}, {3, 4, 5}, {6, 7, 8}};
18+
Real y = f(x, x);
19+
end Subscript5;
20+
21+
22+
// Result:
23+
// function f
24+
// input Real[:, :] x;
25+
// input Real[:, :] y;
26+
// output Real z;
27+
// algorithm
28+
// z := x[1,:] * y[2,:];
29+
// end f;
30+
//
31+
// class Subscript5
32+
// Real x[1,1];
33+
// Real x[1,2];
34+
// Real x[1,3];
35+
// Real x[2,1];
36+
// Real x[2,2];
37+
// Real x[2,3];
38+
// Real x[3,1];
39+
// Real x[3,2];
40+
// Real x[3,3];
41+
// Real y = f(x, x);
42+
// equation
43+
// x = {{time, 1.0, 2.0}, {3.0, 4.0, 5.0}, {6.0, 7.0, 8.0}};
44+
// end Subscript5;
45+
// endResult
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// name: Subscript6
2+
// status: correct
3+
// cflags: -d=newInst
4+
//
5+
//
6+
7+
model Subscript6
8+
Real x[2, 2, 2];
9+
Real y[2];
10+
Integer i;
11+
equation
12+
y = x[i, 2, :] - x[i, 1, :];
13+
end Subscript6;
14+
15+
// Result:
16+
// class Subscript6
17+
// Real x[1,1,1];
18+
// Real x[1,1,2];
19+
// Real x[1,2,1];
20+
// Real x[1,2,2];
21+
// Real x[2,1,1];
22+
// Real x[2,1,2];
23+
// Real x[2,2,1];
24+
// Real x[2,2,2];
25+
// Real y[1];
26+
// Real y[2];
27+
// Integer i;
28+
// equation
29+
// y[1] = x[i,2,1] - x[i,1,1];
30+
// y[2] = x[i,2,2] - x[i,1,2];
31+
// end Subscript6;
32+
// endResult

0 commit comments

Comments
 (0)