This repository has been archived by the owner on Apr 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Belonging to [master]: - OpenModelica/OMCompiler#3001 - #1148
- Loading branch information
1 parent
b14fc7d
commit 4e96c49
Showing
9 changed files
with
215 additions
and
0 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
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,26 @@ | ||
// name: WhenClocked1 | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
|
||
model WhenClocked1 | ||
Real x, y; | ||
equation | ||
when Clock(0.1) then | ||
x + y = 0; | ||
x - y = 0; | ||
end when; | ||
end WhenClocked1; | ||
|
||
// Result: | ||
// class WhenClocked1 | ||
// Real x; | ||
// Real y; | ||
// equation | ||
// when Clock(0.1) then | ||
// x + y = 0.0; | ||
// x - y = 0.0; | ||
// end when; | ||
// end WhenClocked1; | ||
// 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,27 @@ | ||
// name: WhenClockedElse1 | ||
// keywords: | ||
// status: incorrect | ||
// cflags: -d=newInst | ||
// | ||
|
||
model WhenClockedElse1 | ||
Real x, y; | ||
equation | ||
when Clock(0.1) then | ||
x = 0; | ||
y = 1; | ||
elsewhen Clock(0.2) then | ||
x = 2; | ||
y = 3; | ||
end when; | ||
end WhenClockedElse1; | ||
|
||
// Result: | ||
// Error processing file: WhenClockedElse1.mo | ||
// [flattening/modelica/scodeinst/WhenClockedElse1.mo:10:3-16:11:writable] Error: Clocked when equation can not contain elsewhen part. | ||
// | ||
// # Error encountered! Exiting... | ||
// # Please check the error message and the flags. | ||
// | ||
// Execution failed! | ||
// 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,27 @@ | ||
// name: WhenClockedElse2 | ||
// keywords: | ||
// status: incorrect | ||
// cflags: -d=newInst | ||
// | ||
|
||
model WhenClockedElse2 | ||
Real x, y; | ||
equation | ||
when time > 0 then | ||
x = 0; | ||
y = 1; | ||
elsewhen Clock(0.2) then | ||
x = 2; | ||
y = 3; | ||
end when; | ||
end WhenClockedElse2; | ||
|
||
// Result: | ||
// Error processing file: WhenClockedElse2.mo | ||
// [flattening/modelica/scodeinst/WhenClockedElse2.mo:10:3-16:11:writable] Error: Clocked when branch in when equation. | ||
// | ||
// # Error encountered! Exiting... | ||
// # Please check the error message and the flags. | ||
// | ||
// Execution failed! | ||
// 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,24 @@ | ||
// name: WhenClockedStatement1 | ||
// keywords: | ||
// status: incorrect | ||
// cflags: -d=newInst | ||
// | ||
|
||
model WhenClockedStatement1 | ||
Real x, y; | ||
algorithm | ||
when Clock(1) then | ||
x := 0; | ||
y := 1; | ||
end when; | ||
end WhenClockedStatement1; | ||
|
||
// Result: | ||
// Error processing file: WhenClockedStatement1.mo | ||
// [flattening/modelica/scodeinst/WhenClockedStatement1.mo:10:3-13:11:writable] Error: Type error in when conditional 'Clock(1, 1)'. Expected Boolean scalar or vector, got Clock. | ||
// | ||
// # Error encountered! Exiting... | ||
// # Please check the error message and the flags. | ||
// | ||
// Execution failed! | ||
// 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,24 @@ | ||
// name: WhenInvalidEquation1 | ||
// keywords: | ||
// status: incorrect | ||
// cflags: -d=newInst | ||
// | ||
|
||
model WhenInvalidEquation1 | ||
Real x, y; | ||
equation | ||
when time > 0 then | ||
x + y = 0; | ||
x - y = 0; | ||
end when; | ||
end WhenInvalidEquation1; | ||
|
||
// Result: | ||
// Error processing file: WhenInvalidEquation1.mo | ||
// [flattening/modelica/scodeinst/WhenInvalidEquation1.mo:11:5-11:14:writable] Error: Invalid left-hand side of when-equation: x + y. | ||
// | ||
// # Error encountered! Exiting... | ||
// # Please check the error message and the flags. | ||
// | ||
// Execution failed! | ||
// 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,25 @@ | ||
// name: WhenVariableMismatch1 | ||
// keywords: | ||
// status: incorrect | ||
// cflags: -d=newInst | ||
// | ||
|
||
model WhenVariableMismatch1 | ||
Real x, y; | ||
equation | ||
when time > 0 then | ||
x = 0; | ||
elsewhen time > 1 then | ||
y = 0; | ||
end when; | ||
end WhenVariableMismatch1; | ||
|
||
// Result: | ||
// Error processing file: WhenVariableMismatch1.mo | ||
// [flattening/modelica/scodeinst/WhenVariableMismatch1.mo:10:3-14:11:writable] Error: The same variables must be solved in elsewhen clause as in the when clause. | ||
// | ||
// # Error encountered! Exiting... | ||
// # Please check the error message and the flags. | ||
// | ||
// Execution failed! | ||
// 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,25 @@ | ||
// name: WhenVariableMismatch2 | ||
// keywords: | ||
// status: incorrect | ||
// cflags: -d=newInst | ||
// | ||
|
||
model WhenVariableMismatch2 | ||
Real x[2]; | ||
equation | ||
when time > 0 then | ||
x[1] = 0; | ||
elsewhen time > 1 then | ||
x[2] = 0; | ||
end when; | ||
end WhenVariableMismatch2; | ||
|
||
// Result: | ||
// Error processing file: WhenVariableMismatch2.mo | ||
// [flattening/modelica/scodeinst/WhenVariableMismatch2.mo:10:3-14:11:writable] Error: The same variables must be solved in elsewhen clause as in the when clause. | ||
// | ||
// # Error encountered! Exiting... | ||
// # Please check the error message and the flags. | ||
// | ||
// Execution failed! | ||
// 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,29 @@ | ||
// name: WhenVariableMismatch3 | ||
// keywords: | ||
// status: incorrect | ||
// cflags: -d=newInst | ||
// | ||
|
||
model WhenVariableMismatch3 | ||
Real x, y; | ||
equation | ||
when time > 0 then | ||
if x > 0 then | ||
x = 0; | ||
else | ||
y = 0; | ||
end if; | ||
elsewhen time > 1 then | ||
x = 0; | ||
end when; | ||
end WhenVariableMismatch3; | ||
|
||
// Result: | ||
// Error processing file: WhenVariableMismatch3.mo | ||
// [flattening/modelica/scodeinst/WhenVariableMismatch3.mo:11:5-15:11:writable] Error: The branches of an if-equation inside a when-equation must have the same set of component references on the left-hand side. | ||
// | ||
// # Error encountered! Exiting... | ||
// # Please check the error message and the flags. | ||
// | ||
// Execution failed! | ||
// endResult |