-
Notifications
You must be signed in to change notification settings - Fork 298
/
FunctionDefaultArg.mos
48 lines (46 loc) · 1.16 KB
/
FunctionDefaultArg.mos
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// name: FunctionDefaultArg
// status: correct
loadString("
function g
input Real r = 1.5;
output Real o = r;
protected
Real y; // Should not be possible to change
end g;
function f
extends g;
end f;
");getErrorString();
f(r=2.5);getErrorString();
f();getErrorString();
f(x=5.0);getErrorString();
f(y=9.0);getErrorString();
f(4.5);getErrorString();
f(4.5,"abc");getErrorString();
f(4.5,x=1.3);getErrorString();
f(r=1.3,y=2.5);getErrorString();
// Result:
// true
// ""
// 2.5
// ""
// 1.5
// ""
//
// "[flattening/modelica/mosfiles/FunctionDefaultArg.mos:17:1-17:9:writable] Error: Function f has no parameter named x.
// "
//
// "[flattening/modelica/mosfiles/FunctionDefaultArg.mos:18:1-18:9:writable] Error: Function f has no parameter named y.
// "
// 4.5
// ""
//
// "[flattening/modelica/mosfiles/FunctionDefaultArg.mos:20:1-20:13:writable] Error: Failed to elaborate expression: f(4.5, \"abc\").
// "
//
// "[flattening/modelica/mosfiles/FunctionDefaultArg.mos:21:1-21:13:writable] Error: Function f has no parameter named x.
// "
//
// "[flattening/modelica/mosfiles/FunctionDefaultArg.mos:22:1-22:15:writable] Error: Function f has no parameter named y.
// "
// endResult