Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more nfinst tests for builtin operators.
- Loading branch information
1 parent
079d78d
commit 2b1d240
Showing
50 changed files
with
1,213 additions
and
20 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,21 @@ | ||
// name: FuncBuiltinAbs | ||
// keywords: abs | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// Tests the builtin abs function. | ||
// | ||
|
||
model FuncBuiltinAbs | ||
Real r1 = abs(-2.0); | ||
Integer r2 = abs(3); | ||
Real r3 = abs(r1 - r2); | ||
end FuncBuiltinAbs; | ||
|
||
// Result: | ||
// class FuncBuiltinAbs | ||
// Real r1 = abs(-2.0); | ||
// Integer r2 = abs(3); | ||
// Real r3 = abs(r1 - /*Real*/(r2)); | ||
// end FuncBuiltinAbs; | ||
// 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: FuncBuiltinCardinality | ||
// keywords: cardinality | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// Tests the builtin cardinality operator. | ||
// | ||
|
||
model FuncBuiltinCardinality | ||
connector C | ||
Real e; | ||
flow Real f; | ||
end C; | ||
|
||
C c; | ||
Integer r1 = cardinality(c); | ||
end FuncBuiltinCardinality; | ||
|
||
// Result: | ||
// class FuncBuiltinCardinality | ||
// Real c.e; | ||
// Real c.f; | ||
// Integer r1 = 0; | ||
// equation | ||
// c.f = 0.0; | ||
// end FuncBuiltinCardinality; | ||
// 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,21 @@ | ||
// name: FuncBuiltinCeil | ||
// keywords: ceil | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// Tests the builtin ceil function. | ||
// | ||
|
||
model FuncBuiltinCeil | ||
Real r1 = ceil(4.25); | ||
Real r2 = ceil(-7.9); | ||
Real r3 = ceil(r1 / r2); | ||
end FuncBuiltinCeil; | ||
|
||
// Result: | ||
// class FuncBuiltinCeil | ||
// Real r1 = ceil(4.25); | ||
// Real r2 = ceil(-7.9); | ||
// Real r3 = ceil(r1 / r2); | ||
// end FuncBuiltinCeil; | ||
// 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: FuncBuiltinChange | ||
// keywords: change | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// Tests the builtin change operator. | ||
// | ||
|
||
model FuncBuiltinChange | ||
discrete Real x; | ||
Boolean y = change(x); | ||
end FuncBuiltinChange; | ||
|
||
// Result: | ||
// Error processing file: FuncBuiltinChange.mo | ||
// [flattening/modelica/scodeinst/FuncBuiltinChange.mo:11:3-11:24:writable] Error: No matching function found for change(x) in component <REMOVE ME> | ||
// candidates are : | ||
// change() | ||
// | ||
// # 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,21 @@ | ||
// name: FuncBuiltinCross | ||
// keywords: cross | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// Tests the builtin cross operator. | ||
// | ||
|
||
model FuncBuiltinCross | ||
Real x[3] = cross({1, 2, 3}, {4, 5, 6}); | ||
end FuncBuiltinCross; | ||
|
||
// Result: | ||
// Error processing file: FuncBuiltinCross.mo | ||
// Error: Internal error Instantiation of FuncBuiltinCross failed with no error message. | ||
// | ||
// # 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,21 @@ | ||
// name: FuncBuiltinDelay | ||
// keywords: delay | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// Tests the builtin delay operator. | ||
// | ||
|
||
model FuncBuiltinDelay | ||
Real x = time; | ||
Real y = delay(x, 1.0); | ||
Real z = delay(x, 2.0, 3.0); | ||
end FuncBuiltinDelay; | ||
|
||
// Result: | ||
// class FuncBuiltinDelay | ||
// Real x = time; | ||
// Real y = delay(x, 1.0); | ||
// Real z = delay(x, 2.0, 3.0); | ||
// end FuncBuiltinDelay; | ||
// 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,19 @@ | ||
// name: FuncBuiltinDer | ||
// keywords: der | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// Tests the builtin der operator. | ||
// | ||
|
||
model FuncBuiltinDer | ||
Real x = time; | ||
Real y = der(x); | ||
end FuncBuiltinDer; | ||
|
||
// Result: | ||
// class FuncBuiltinDer | ||
// Real x = time; | ||
// Real y = der(x); | ||
// end FuncBuiltinDer; | ||
// 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,21 @@ | ||
// name: FuncBuiltinDiagonal | ||
// keywords: diagonal | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// Tests the builtin diagonal operator. | ||
// | ||
|
||
model FuncBuiltinDiagonal | ||
Real x[3,3] = diagonal({1, 2, 3}); | ||
end FuncBuiltinDiagonal; | ||
|
||
// Result: | ||
// Error processing file: FuncBuiltinDiagonal.mo | ||
// Error: Base class polymorphic not found in scope <unknown>. | ||
// | ||
// # 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,21 @@ | ||
// name: FuncBuiltinDiv | ||
// keywords: div | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// Tests the builtin div function. | ||
// | ||
|
||
model FuncBuiltinDiv | ||
Integer r1 = div(6, 2); | ||
Real r2 = div(8, 1.5); | ||
Real r3 = div(25.0, 4.0); | ||
end FuncBuiltinDiv; | ||
|
||
// Result: | ||
// class FuncBuiltinDiv | ||
// Integer r1 = div(6, 2); | ||
// Real r2 = div(8.0, 1.5); | ||
// Real r3 = div(25.0, 4.0); | ||
// end FuncBuiltinDiv; | ||
// 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,19 @@ | ||
// name: FuncBuiltinEdge | ||
// keywords: edge | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// Tests the builtin edge operator. | ||
// | ||
|
||
model FuncBuiltinEdge | ||
discrete Boolean b1; | ||
Boolean b2 = edge(b1); | ||
end FuncBuiltinEdge; | ||
|
||
// Result: | ||
// class FuncBuiltinEdge | ||
// discrete Boolean b1; | ||
// Boolean b2 = edge(b1); | ||
// end FuncBuiltinEdge; | ||
// 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,19 @@ | ||
// name: FuncBuiltinEnumTypeName | ||
// keywords: enumeration | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// Tests that enumeration type names can be used to convert an Integer to an | ||
// enumeration value. | ||
// | ||
|
||
model FuncBuiltinEnumTypeName | ||
type E = enumeration(one, two, three); | ||
E e = E(2); | ||
end FuncBuiltinEnumTypeName; | ||
|
||
// Result: | ||
// class FuncBuiltinEnumTypeName | ||
// enumeration(one, two, three) e = E.two; | ||
// end FuncBuiltinEnumTypeName; | ||
// 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: FuncBuiltinFill | ||
// keywords: fill | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// Tests the builtin fill operator. | ||
// | ||
|
||
model FuncBuiltinFill | ||
Real x[4] = fill(1, 4); | ||
Real y[2, 4, 1] = fill(3.14, 2, 4, 1); | ||
end FuncBuiltinFill; | ||
|
||
// Result: | ||
// Error processing file: FuncBuiltinFill.mo | ||
// [flattening/modelica/scodeinst/FuncBuiltinFill.mo:11:3-11:40:writable] Error: No matching function found for fill(3.14, 2, 4, 1) in component <REMOVE ME> | ||
// candidates are : | ||
// fill(s, n) | ||
// | ||
// # 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,21 @@ | ||
// name: FuncBuiltinFloor | ||
// keywords: floor | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// Tests the builtin floor function. | ||
// | ||
|
||
model FuncBuiltinFloor | ||
Real r1 = floor(4.25); | ||
Real r2 = floor(-7.9); | ||
Real r3 = floor(r1 / r2); | ||
end FuncBuiltinFloor; | ||
|
||
// Result: | ||
// class FuncBuiltinFloor | ||
// Real r1 = floor(4.25); | ||
// Real r2 = floor(-7.9); | ||
// Real r3 = floor(r1 / r2); | ||
// end FuncBuiltinFloor; | ||
// endResult |
17 changes: 17 additions & 0 deletions
17
flattening/modelica/scodeinst/FuncBuiltinGetInstanceName.mo
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,17 @@ | ||
// name: FuncBuiltinGetInstanceName | ||
// keywords: getInstanceName | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// Tests the builtin getInstanceName operator. | ||
// | ||
|
||
model FuncBuiltinGetInstanceName | ||
String s = getInstanceName(); | ||
end FuncBuiltinGetInstanceName; | ||
|
||
// Result: | ||
// class FuncBuiltinGetInstanceName | ||
// String s = getInstanceName(); | ||
// end FuncBuiltinGetInstanceName; | ||
// 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: FuncBuiltinHomotopy | ||
// keywords: homotopy | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// Tests the builtin homotopy operator. | ||
// | ||
|
||
model FuncBuiltinHomotopy | ||
Real x = 1.0; | ||
Real y = time; | ||
Real r1 = homotopy(x, y); | ||
Real r2 = homotopy(actual = x, simplified = y); | ||
Real r3 = homotopy(x, simplified = y); | ||
end FuncBuiltinHomotopy; | ||
|
||
// Result: | ||
// class FuncBuiltinHomotopy | ||
// Real x = 1.0; | ||
// Real y = time; | ||
// Real r1 = homotopy(x, y); | ||
// Real r2 = homotopy(x, y); | ||
// Real r3 = homotopy(x, y); | ||
// end FuncBuiltinHomotopy; | ||
// 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,21 @@ | ||
// name: FuncBuiltinIdentity | ||
// keywords: identity | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// Tests the builtin identity operator. | ||
// | ||
|
||
model FuncBuiltinIdentity | ||
Real x[3,3] = identity(3); | ||
end FuncBuiltinIdentity; | ||
|
||
// Result: | ||
// Error processing file: FuncBuiltinIdentity.mo | ||
// [lib/omc/ModelicaBuiltin.mo:139:3-139:47:writable] Error: Dimensions must be parameter or constant expression (in arraySize). | ||
// | ||
// # 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,17 @@ | ||
// name: FuncBuiltinInitial | ||
// keywords: initial | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// Tests the builtin initial operator. | ||
// | ||
|
||
model FuncBuiltinInitial | ||
Boolean s = initial(); | ||
end FuncBuiltinInitial; | ||
|
||
// Result: | ||
// class FuncBuiltinInitial | ||
// Boolean s = initial(); | ||
// end FuncBuiltinInitial; | ||
// endResult |
Oops, something went wrong.