Skip to content

Commit

Permalink
Added some for loop test for scodeinst
Browse files Browse the repository at this point in the history
  • Loading branch information
perost authored and OpenModelica-Hudson committed Mar 14, 2017
1 parent bfc0be7 commit 1e13743
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 1 deletion.
26 changes: 26 additions & 0 deletions flattening/modelica/scodeinst/ForEquationNonParam.mo
@@ -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
28 changes: 28 additions & 0 deletions flattening/modelica/scodeinst/ForStatement1.mo
@@ -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
30 changes: 30 additions & 0 deletions flattening/modelica/scodeinst/ForStatement2.mo
@@ -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
28 changes: 28 additions & 0 deletions flattening/modelica/scodeinst/ForStatementArray.mo
@@ -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
23 changes: 23 additions & 0 deletions flattening/modelica/scodeinst/ForStatementNonVector.mo
@@ -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
7 changes: 6 additions & 1 deletion flattening/modelica/scodeinst/Makefile
Expand Up @@ -46,6 +46,11 @@ eq7.mo \
eq10.mo \
extends3.mo \
ExtendSections.mo \
ForEquationNonParam.mo \
ForStatement1.mo \
ForStatement2.mo \
ForStatementArray.mo \
ForStatementNonVector.mo \
FuncBuiltinAbs.mo \
FuncBuiltinCeil.mo \
FuncBuiltinDelay.mo \
Expand Down Expand Up @@ -191,7 +196,6 @@ eq9.mo \
expconn4.mo \
expconn7.mo \
ExtendsVisibility.mo \
for3.mo \
func1.mo \
func2.mo \
func4.mo \
Expand Down Expand Up @@ -277,6 +281,7 @@ extends1.mo \
extends2.mo \
for1.mo \
for2.mo \
for3.mo \
function1.mo \
FunctionRecordArg1.mo \
ImportUnqualified2.mo \
Expand Down

0 comments on commit 1e13743

Please sign in to comment.