Skip to content
This repository was archived by the owner on Apr 3, 2019. It is now read-only.

Commit f193e07

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Add more when tests.
Belonging to [master]: - OpenModelica/OMCompiler#3011 - #1151
1 parent 3c40164 commit f193e07

3 files changed

Lines changed: 83 additions & 0 deletions

File tree

flattening/modelica/scodeinst/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,8 @@ When3.mo \
819819
When4.mo \
820820
When5.mo \
821821
When6.mo \
822+
When7.mo \
823+
When8.mo \
822824
WhenClocked1.mo \
823825
WhenClockedElse1.mo \
824826
WhenClockedElse2.mo \
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// name: When7
2+
// keywords:
3+
// status: correct
4+
// cflags: -d=newInst
5+
//
6+
//
7+
8+
model When7
9+
Real x;
10+
equation
11+
when time > 0 then
12+
x = 1;
13+
elsewhen time > 1 then
14+
reinit(x, 2);
15+
end when;
16+
end When7;
17+
18+
// Result:
19+
// class When7
20+
// Real x;
21+
// equation
22+
// when time > 0.0 then
23+
// x = 1.0;
24+
// elsewhen time > 1.0 then
25+
// reinit(x, 2.0);
26+
// end when;
27+
// end When7;
28+
// endResult
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// name: When8
2+
// keywords:
3+
// status: correct
4+
// cflags: -d=newInst
5+
//
6+
//
7+
8+
model When8
9+
Real x[3];
10+
Real y;
11+
Real z[3];
12+
equation
13+
when time > 0 then
14+
x = {1, 2, 3};
15+
y = 2;
16+
z = {4, 5, 6};
17+
elsewhen time > 1 then
18+
x[1:2] = {3, 2};
19+
x[3] = 5;
20+
z = {9, 8, 7};
21+
y = 4;
22+
end when;
23+
end When8;
24+
25+
// Result:
26+
// class When8
27+
// Real x[1];
28+
// Real x[2];
29+
// Real x[3];
30+
// Real y;
31+
// Real z[1];
32+
// Real z[2];
33+
// Real z[3];
34+
// equation
35+
// when time > 0.0 then
36+
// x[1] = 1.0;
37+
// x[2] = 2.0;
38+
// x[3] = 3.0;
39+
// y = 2.0;
40+
// z[1] = 4.0;
41+
// z[2] = 5.0;
42+
// z[3] = 6.0;
43+
// elsewhen time > 1.0 then
44+
// x[1] = 3.0;
45+
// x[2] = 2.0;
46+
// x[3] = 5.0;
47+
// z[1] = 9.0;
48+
// z[2] = 8.0;
49+
// z[3] = 7.0;
50+
// y = 4.0;
51+
// end when;
52+
// end When8;
53+
// endResult

0 commit comments

Comments
 (0)