Skip to content

Commit

Permalink
Added some nfinst test cases for size.
Browse files Browse the repository at this point in the history
  • Loading branch information
perost authored and OpenModelica-Hudson committed Aug 23, 2017
1 parent e5d7afe commit bf355bb
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 0 deletions.
5 changes: 5 additions & 0 deletions flattening/modelica/scodeinst/Makefile
Expand Up @@ -191,6 +191,11 @@ redeclare2.mo \
redeclare6.mo \
redeclare7.mo \
redeclare9.mo \
Size1.mo \
SizeInvalidArgs1.mo \
SizeInvalidArgs2.mo \
SizeInvalidType1.mo \
SizeInvalidType2.mo \
Subscript1.mo \
type2.mo \
usertype1.mo \
Expand Down
21 changes: 21 additions & 0 deletions flattening/modelica/scodeinst/Size1.mo
@@ -0,0 +1,21 @@
// name: Size1
// keywords: size
// status: correct
// cflags: -d=newInst
//
// Tests the builtin size operator.
//

model Size1
Real x[3];
Integer y = size(x, 1);
end Size1;

// Result:
// class Size1
// Real x[1];
// Real x[2];
// Real x[3];
// Integer y = size(x, 1);
// end Size1;
// endResult
25 changes: 25 additions & 0 deletions flattening/modelica/scodeinst/SizeInvalidArgs1.mo
@@ -0,0 +1,25 @@
// name: SizeInvalidArgs1
// keywords: size
// status: incorrect
// cflags: -d=newInst
//
// Tests the builtin size operator.
//

model SizeInvalidArgs1
Real x[3];
Integer y = size(x, 1, 2);
end SizeInvalidArgs1;

// Result:
// Error processing file: SizeInvalidArgs1.mo
// [flattening/modelica/scodeinst/SizeInvalidArgs1.mo:11:3-11:28:writable] Error: No matching function found for size in component
// candidates are :
// size(array) => Integer[:]
// size(array, Integer) => Integer
//
// # Error encountered! Exiting...
// # Please check the error message and the flags.
//
// Execution failed!
// endResult
22 changes: 22 additions & 0 deletions flattening/modelica/scodeinst/SizeInvalidArgs2.mo
@@ -0,0 +1,22 @@
// name: SizeInvalidArgs2
// keywords: size
// status: incorrect
// cflags: -d=newInst
//
// Tests the builtin size operator.
//

model SizeInvalidArgs2
Real x[3];
Integer y = size(x, dim = 1);
end SizeInvalidArgs2;

// Result:
// Error processing file: SizeInvalidArgs2.mo
// [flattening/modelica/scodeinst/SizeInvalidArgs2.mo:11:3-11:31:writable] Error: Function size has no parameter named dim.
//
// # Error encountered! Exiting...
// # Please check the error message and the flags.
//
// Execution failed!
// endResult
25 changes: 25 additions & 0 deletions flattening/modelica/scodeinst/SizeInvalidType1.mo
@@ -0,0 +1,25 @@
// name: SizeInvalidType1
// keywords: size
// status: incorrect
// cflags: -d=newInst
//
// Tests the builtin size operator.
//

model SizeInvalidType1
Real x[3];
Integer y = size(x, "1");
end SizeInvalidType1;

// Result:
// Error processing file: SizeInvalidType1.mo
// [flattening/modelica/scodeinst/SizeInvalidType1.mo:11:3-11:27:writable] Error: Type mismatch for positional argument 2 in size (dim="1"). The argument has type:
// String
// expected type:
// Integer
//
// # Error encountered! Exiting...
// # Please check the error message and the flags.
//
// Execution failed!
// endResult
22 changes: 22 additions & 0 deletions flattening/modelica/scodeinst/SizeInvalidType2.mo
@@ -0,0 +1,22 @@
// name: SizeInvalidType2
// keywords: size
// status: incorrect
// cflags: -d=newInst
//
// Tests the builtin size operator.
//

model SizeInvalidType2
Real x[3];
Integer y = size("array", 1);
end SizeInvalidType2;

// Result:
// Error processing file: SizeInvalidType2.mo
// [flattening/modelica/scodeinst/SizeInvalidType2.mo:11:3-11:31:writable] Error: The first argument of size must be an array expression.
//
// # Error encountered! Exiting...
// # Please check the error message and the flags.
//
// Execution failed!
// endResult

0 comments on commit bf355bb

Please sign in to comment.