Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added some for loop test for scodeinst
- Loading branch information
1 parent
bfc0be7
commit 1e13743
Showing
6 changed files
with
141 additions
and
1 deletion.
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,26 @@ | ||
// name: ForEquationNonPAram.mo | ||
// keywords: | ||
// status: incorrect | ||
// cflags: -d=newInst | ||
// | ||
// Checks that the range of a for loop equation must be a parameter expression. | ||
// | ||
|
||
model ForEquationNonParam | ||
Real x[5]; | ||
Real y = time; | ||
equation | ||
for i in 1:y loop | ||
x[i] = i; | ||
end for; | ||
end ForEquationNonParam; | ||
|
||
// Result: | ||
// Error processing file: ForEquationNonParam.mo | ||
// [flattening/modelica/scodeinst/ForEquationNonParam.mo:13:3-15:10:writable] Error: The iteration range 1:y is not a constant or parameter expression. | ||
// | ||
// # 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,28 @@ | ||
// name: ForStatement1.mo | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// | ||
|
||
model ForStatement1 | ||
Real x[5]; | ||
algorithm | ||
for i in 1:5 loop | ||
x[i] := i; | ||
end for; | ||
end ForStatement1; | ||
|
||
// Result: | ||
// class ForStatement1 | ||
// Real x[1]; | ||
// Real x[2]; | ||
// Real x[3]; | ||
// Real x[4]; | ||
// Real x[5]; | ||
// algorithm | ||
// for i in 1:5 loop | ||
// x[i] := i; | ||
// end for; | ||
// end ForStatement1; | ||
// 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: ForStatement2.mo | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// | ||
|
||
model ForStatement2 | ||
Real x[5]; | ||
constant Integer s = 5; | ||
algorithm | ||
for i in 1:s loop | ||
x[i] := i; | ||
end for; | ||
end ForStatement2; | ||
|
||
// Result: | ||
// class ForStatement2 | ||
// Real x[1]; | ||
// Real x[2]; | ||
// Real x[3]; | ||
// Real x[4]; | ||
// Real x[5]; | ||
// constant Integer s = 5; | ||
// algorithm | ||
// for i in 1:s loop | ||
// x[i] := i; | ||
// end for; | ||
// end ForStatement2; | ||
// 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,28 @@ | ||
// name: ForStatementArray.mo | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// | ||
|
||
model ForStatementArray | ||
Real x[5]; | ||
algorithm | ||
for i in {1, 2, 3, 4, 5} loop | ||
x[i] := i; | ||
end for; | ||
end ForStatementArray; | ||
|
||
// Result: | ||
// class ForStatementArray | ||
// Real x[1]; | ||
// Real x[2]; | ||
// Real x[3]; | ||
// Real x[4]; | ||
// Real x[5]; | ||
// algorithm | ||
// for i in {1, 2, 3, 4, 5} loop | ||
// x[i] := i; | ||
// end for; | ||
// end ForStatementArray; | ||
// 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,23 @@ | ||
// name: ForStatementNonVector.mo | ||
// keywords: | ||
// status: incorrect | ||
// cflags: -d=newInst | ||
// | ||
|
||
model ForStatementNonVector | ||
Real x; | ||
equation | ||
for i in 1 loop | ||
x = x; | ||
end for; | ||
end ForStatementNonVector; | ||
|
||
// Result: | ||
// Error processing file: ForStatementNonVector.mo | ||
// [flattening/modelica/scodeinst/ForStatementNonVector.mo:10:3-12:10:writable] Error: Type error in iteration range '1'. Expected array got Integer. | ||
// | ||
// # 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