Skip to content

Commit

Permalink
[NF] Add record inheritance tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
perost authored and OpenModelica-Hudson committed Nov 28, 2018
1 parent e49f7dc commit 2f21e5a
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
2 changes: 2 additions & 0 deletions flattening/modelica/scodeinst/Makefile
Expand Up @@ -655,6 +655,8 @@ RecordBinding1.mo \
RecordBinding2.mo \
RecordBinding3.mo \
RecordBinding4.mo \
RecordExtends1.mo \
RecordExtends2.mo \
RecursiveExtends1.mo \
RecursiveExtends3.mo \
RedeclareClass1.mo \
Expand Down
31 changes: 31 additions & 0 deletions flattening/modelica/scodeinst/RecordExtends1.mo
@@ -0,0 +1,31 @@
// name: RecordExtends1
// keywords:
// status: correct
// cflags: -d=newInst
//

record R
Real x;
end R;

model M1
record R1 = R(x = 1.0);
R1 r1;
end M1;

model M2
record R2 = R(x = 2.0);
R2 r2;
end M2;

model RecordExtends1
M1 m1;
M2 m2;
end RecordExtends1;

// Result:
// class RecordExtends1
// Real m1.r1.x = 1.0;
// Real m2.r2.x = 2.0;
// end RecordExtends1;
// endResult
39 changes: 39 additions & 0 deletions flattening/modelica/scodeinst/RecordExtends2.mo
@@ -0,0 +1,39 @@
// name: RecordExtends2
// keywords:
// status: correct
// cflags: -d=newInst
//

package P
constant Integer n;

record R
Real x[n];
end R;
end P;

model M1
package P1 = P(n = 1);
P1.R r1 = P1.R({1.0});
end M1;

model M2
package P2 = P(n = 2);
P2.R r2 = P2.R({1.0, 2.0});
end M2;

model RecordExtends2
M1 m1;
M2 m2;
end RecordExtends2;

// Result:
// class RecordExtends2
// Real m1.r1.x[1];
// Real m2.r2.x[1];
// Real m2.r2.x[2];
// equation
// m1.r1.x = {1.0};
// m2.r2.x = {1.0, 2.0};
// end RecordExtends2;
// endResult

0 comments on commit 2f21e5a

Please sign in to comment.