Skip to content

Commit

Permalink
[NF] Add more when tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
perost authored and OpenModelica-Hudson committed Mar 28, 2019
1 parent 3c40164 commit f193e07
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
2 changes: 2 additions & 0 deletions flattening/modelica/scodeinst/Makefile
Expand Up @@ -819,6 +819,8 @@ When3.mo \
When4.mo \
When5.mo \
When6.mo \
When7.mo \
When8.mo \
WhenClocked1.mo \
WhenClockedElse1.mo \
WhenClockedElse2.mo \
Expand Down
28 changes: 28 additions & 0 deletions flattening/modelica/scodeinst/When7.mo
@@ -0,0 +1,28 @@
// name: When7
// keywords:
// status: correct
// cflags: -d=newInst
//
//

model When7
Real x;
equation
when time > 0 then
x = 1;
elsewhen time > 1 then
reinit(x, 2);
end when;
end When7;

// Result:
// class When7
// Real x;
// equation
// when time > 0.0 then
// x = 1.0;
// elsewhen time > 1.0 then
// reinit(x, 2.0);
// end when;
// end When7;
// endResult
53 changes: 53 additions & 0 deletions flattening/modelica/scodeinst/When8.mo
@@ -0,0 +1,53 @@
// name: When8
// keywords:
// status: correct
// cflags: -d=newInst
//
//

model When8
Real x[3];
Real y;
Real z[3];
equation
when time > 0 then
x = {1, 2, 3};
y = 2;
z = {4, 5, 6};
elsewhen time > 1 then
x[1:2] = {3, 2};
x[3] = 5;
z = {9, 8, 7};
y = 4;
end when;
end When8;

// Result:
// class When8
// Real x[1];
// Real x[2];
// Real x[3];
// Real y;
// Real z[1];
// Real z[2];
// Real z[3];
// equation
// when time > 0.0 then
// x[1] = 1.0;
// x[2] = 2.0;
// x[3] = 3.0;
// y = 2.0;
// z[1] = 4.0;
// z[2] = 5.0;
// z[3] = 6.0;
// elsewhen time > 1.0 then
// x[1] = 3.0;
// x[2] = 2.0;
// x[3] = 5.0;
// z[1] = 9.0;
// z[2] = 8.0;
// z[3] = 7.0;
// y = 4.0;
// end when;
// end When8;
// endResult

0 comments on commit f193e07

Please sign in to comment.