Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NF] Add record array evaluation tests.
Belonging to [master]: - OpenModelica/OMCompiler#2517 - OpenModelica/OpenModelica-testsuite#979
- Loading branch information
1 parent
bede778
commit fb83712
Showing
7 changed files
with
202 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// name: CevalRecordArray1 | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
|
||
record R | ||
Real x; | ||
Real y; | ||
Real z; | ||
end R; | ||
|
||
model CevalRecordArray1 | ||
constant R r[2] = {R(1.0, 2.0, 3.0), R(4.0, 5.0, 6.0)}; | ||
Real x[2] = r.x; | ||
Real y[2] = r.y; | ||
Real z[2] = r.z; | ||
end CevalRecordArray1; | ||
|
||
// Result: | ||
// class CevalRecordArray1 | ||
// constant Real r[1].x = 1.0; | ||
// constant Real r[1].y = 2.0; | ||
// constant Real r[1].z = 3.0; | ||
// constant Real r[2].x = 4.0; | ||
// constant Real r[2].y = 5.0; | ||
// constant Real r[2].z = 6.0; | ||
// Real x[1]; | ||
// Real x[2]; | ||
// Real y[1]; | ||
// Real y[2]; | ||
// Real z[1]; | ||
// Real z[2]; | ||
// equation | ||
// x = {1.0, 4.0}; | ||
// y = {2.0, 5.0}; | ||
// z = {3.0, 6.0}; | ||
// end CevalRecordArray1; | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// name: CevalRecordArray2 | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
|
||
package P | ||
record R | ||
Real x = 1.0; | ||
Real y = 2.0; | ||
Real z = 3.0; | ||
end R; | ||
|
||
constant R r[2]; | ||
|
||
function f | ||
input Real x; | ||
output Real y; | ||
algorithm | ||
y := x * r[2].y; | ||
end f; | ||
end P; | ||
|
||
|
||
model CevalRecordArray2 | ||
Real x = P.f(1.0); | ||
end CevalRecordArray2; | ||
|
||
// Result: | ||
// function P.f | ||
// input Real x; | ||
// output Real y; | ||
// algorithm | ||
// y := x * 2.0; | ||
// end P.f; | ||
// | ||
// class CevalRecordArray2 | ||
// Real x = P.f(1.0); | ||
// end CevalRecordArray2; | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// name: CevalRecordArray3 | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
|
||
record R | ||
Real x; | ||
Real y; | ||
Real z; | ||
end R; | ||
|
||
model CevalRecordArray3 | ||
constant R r[2](each x = 1.0, y = {2, 3}, z = {4, 5}); | ||
Real r1[2] = r.x; | ||
Real r2[2] = r.y; | ||
Real r3[2] = r.z; | ||
Real r4 = r[2].x; | ||
Real r5 = r[1].y; | ||
end CevalRecordArray3; | ||
|
||
// Result: | ||
// class CevalRecordArray3 | ||
// constant Real r[1].x = 1.0; | ||
// constant Real r[1].y = 2.0; | ||
// constant Real r[1].z = 4.0; | ||
// constant Real r[2].x = 1.0; | ||
// constant Real r[2].y = 3.0; | ||
// constant Real r[2].z = 5.0; | ||
// Real r1[1]; | ||
// Real r1[2]; | ||
// Real r2[1]; | ||
// Real r2[2]; | ||
// Real r3[1]; | ||
// Real r3[2]; | ||
// Real r4 = 1.0; | ||
// Real r5 = 2.0; | ||
// equation | ||
// r1 = {1.0, 1.0}; | ||
// r2 = {2.0, 3.0}; | ||
// r3 = {4.0, 5.0}; | ||
// end CevalRecordArray3; | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// name: CevalRecordArray4 | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
|
||
record R | ||
Real x = 1.0; | ||
Real y = 2.0; | ||
Real z = 3.0; | ||
end R; | ||
|
||
model CevalRecordArray4 | ||
constant R r1[2]; | ||
Real x = r1[1].x; | ||
Real y = r1[2].y; | ||
end CevalRecordArray4; | ||
|
||
// Result: | ||
// class CevalRecordArray4 | ||
// constant Real r1[1].x = 1.0; | ||
// constant Real r1[1].y = 2.0; | ||
// constant Real r1[1].z = 3.0; | ||
// constant Real r1[2].x = 1.0; | ||
// constant Real r1[2].y = 2.0; | ||
// constant Real r1[2].z = 3.0; | ||
// Real x = 1.0; | ||
// Real y = 2.0; | ||
// end CevalRecordArray4; | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// name: CevalRecordArray5 | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
|
||
record R | ||
Real x; | ||
Real y; | ||
Real z; | ||
end R; | ||
|
||
model CevalRecordArray5 | ||
constant R r[1] = {R(1.0, 2.0, 3.0)}; | ||
Real r1 = r[1].x; | ||
Real r2 = r[1].y; | ||
Real r3 = r[1].z; | ||
Real r4[1] = r.x; | ||
Real r5[1] = r.y; | ||
Real r6[1] = r.z; | ||
end CevalRecordArray5; | ||
|
||
// Result: | ||
// class CevalRecordArray5 | ||
// constant Real r[1].x = 1.0; | ||
// constant Real r[1].y = 2.0; | ||
// constant Real r[1].z = 3.0; | ||
// Real r1 = 1.0; | ||
// Real r2 = 2.0; | ||
// Real r3 = 3.0; | ||
// Real r4[1]; | ||
// Real r5[1]; | ||
// Real r6[1]; | ||
// equation | ||
// r4 = {1.0}; | ||
// r5 = {2.0}; | ||
// r6 = {3.0}; | ||
// end CevalRecordArray5; | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters