Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update tests for NFFrontEnd function changes.
- Add tests for user defined overloading
- Loading branch information
1 parent
984eeea
commit 2b02a60
Showing
15 changed files
with
268 additions
and
15 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
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
37 changes: 37 additions & 0 deletions
37
flattening/modelica/scodeinst/FuncOverloadAmbiguousDefault.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,37 @@ | ||
// name: FuncOverloadAmbiguousDefault | ||
// keywords: overload | ||
// status: incorrect | ||
// cflags: -d=newInst | ||
// | ||
// Tests an ambigous overload due to default values. | ||
// | ||
model FuncOverloadAmbiguousDefault | ||
function F | ||
input Integer f1; | ||
output Integer f2; | ||
end F; | ||
|
||
function G | ||
input Integer g1; | ||
input Integer g2 = 1; | ||
output Integer g3; | ||
end G; | ||
|
||
function OV = $overload(F,G); | ||
|
||
Integer x = OV(1); | ||
end FuncOverloadAmbiguousDefault; | ||
|
||
// Result: | ||
// Ambiguous call: OV(1) | ||
// Candidates: | ||
// OV(Integer g1, Integer g2 = 1) => Integer | ||
// OV(Integer f1) => Integer | ||
// Error processing file: FuncOverloadAmbiguousDefault.mo | ||
// Error: Internal error Instantiation of FuncOverloadAmbiguousDefault 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,43 @@ | ||
// name: FuncOverloadExactPrefer | ||
// keywords: overload, cast | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// Tests proper selection of exact matches over converted matches. | ||
// Compare with FuncOverloadAmbiguousDefault | ||
// | ||
model FuncOverloadExactPrefer | ||
function F | ||
input Integer f1; | ||
output Integer f2; | ||
end F; | ||
|
||
function G | ||
input Real g1; | ||
input Integer g2 = 1; | ||
output Integer g3; | ||
end G; | ||
|
||
function OV = $overload(F,G); | ||
|
||
Integer x = OV(1); | ||
Integer x = OV(1.0); | ||
end FuncOverloadExactPrefer; | ||
|
||
// Result: | ||
// function F | ||
// input Integer f1; | ||
// output Integer f2; | ||
// end F; | ||
// | ||
// function G | ||
// input Real g1; | ||
// input Integer g2 = 1; | ||
// output Integer g3; | ||
// end G; | ||
// | ||
// class FuncOverloadExactPrefer | ||
// Integer x = F(1); | ||
// Integer x = G(1.0, 1); | ||
// end FuncOverloadExactPrefer; | ||
// 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,54 @@ | ||
// name: FuncOverloadMulti | ||
// keywords: overload, cast | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// Tests handling of multiple overload, i.e, and overload of overloaded function | ||
// | ||
model FuncOverloadMulti | ||
function int_string | ||
input Integer f1; | ||
output String f2; | ||
end int_string; | ||
|
||
function real_string | ||
input Real g1; | ||
output Integer g3; | ||
end real_string; | ||
|
||
function numeric_string = $overload(int_string,real_string); | ||
|
||
function bool_string | ||
input Boolean g1; | ||
output Integer g3; | ||
end bool_string; | ||
|
||
function any_string = $overload(numeric_string,bool_string); | ||
|
||
String x = any_string(true); | ||
String x = any_string(1); | ||
String x = any_string(1.0); | ||
end FuncOverloadMulti; | ||
|
||
// Result: | ||
// function bool_string | ||
// input Boolean g1; | ||
// output Integer g3; | ||
// end bool_string; | ||
// | ||
// function int_string | ||
// input Integer f1; | ||
// output String f2; | ||
// end int_string; | ||
// | ||
// function real_string | ||
// input Real g1; | ||
// output Integer g3; | ||
// end real_string; | ||
// | ||
// class FuncOverloadMulti | ||
// String x = bool_string(true); | ||
// String x = int_string(1); | ||
// String x = real_string(1.0); | ||
// end FuncOverloadMulti; | ||
// 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,43 @@ | ||
// name: FuncOverloadNoMatch | ||
// keywords: overload | ||
// status: incorrect | ||
// cflags: -d=newInst | ||
// | ||
// Tests that proper error messages are printed for no overload match | ||
// | ||
model FuncOverloadNoMatch | ||
function F | ||
input Integer f1; | ||
output Integer f2; | ||
end F; | ||
|
||
function G | ||
input Real g1; | ||
output Integer g3; | ||
end G; | ||
|
||
function OV = $overload(F,G); | ||
|
||
Integer x = OV(true); | ||
end FuncOverloadNoMatch; | ||
|
||
// Result: | ||
// Error processing file: FuncOverloadNoMatch.mo | ||
// [flattening/modelica/scodeinst/FuncOverloadNoMatch.mo:21:3-21:23:writable] Error: Type mismatch for positional argument 1 in F(f1=true). The argument has type: | ||
// Boolean | ||
// expected type: | ||
// Integer | ||
// [flattening/modelica/scodeinst/FuncOverloadNoMatch.mo:21:3-21:23:writable] Error: Type mismatch for positional argument 1 in G(g1=true). The argument has type: | ||
// Boolean | ||
// expected type: | ||
// Real | ||
// [flattening/modelica/scodeinst/FuncOverloadNoMatch.mo:21:3-21:23:writable] Error: No matching function found for OV(true) in component <REMOVE ME> | ||
// candidates are : | ||
// OV(Integer f1) => Integer | ||
// OV(Real g1) => 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// name: FuncSimpleOverload | ||
// keywords: overload | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// Tests simple overloading. | ||
// | ||
model FuncSimpleOverload | ||
function F | ||
input Integer f1; | ||
output Integer f2; | ||
end F; | ||
|
||
function G | ||
input Integer g1; | ||
input Integer g2; | ||
output Integer g3; | ||
end G; | ||
|
||
function OV = $overload(F,G); | ||
|
||
Integer x = OV(1); | ||
Integer y = OV(1,2); | ||
end FuncSimpleOverload; | ||
|
||
// Result: | ||
// function F | ||
// input Integer f1; | ||
// output Integer f2; | ||
// end F; | ||
// | ||
// function G | ||
// input Integer g1; | ||
// input Integer g2; | ||
// output Integer g3; | ||
// end G; | ||
// | ||
// class FuncSimpleOverload | ||
// Integer x = F(1); | ||
// Integer y = G(1, 2); | ||
// end FuncSimpleOverload; | ||
// 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
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
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
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