-
Notifications
You must be signed in to change notification settings - Fork 298
/
UnitCheck13.mos
50 lines (47 loc) · 1.19 KB
/
UnitCheck13.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
49
50
// name: UnitCheck13
// keywords: initialization
// status: correct
loadString("
package unitCheckTests
model UnitCheck13
Real V;
Real A;
Real S(unit = \"m2\");
equation
A = 5.0;
S = V^2 + sqrt(A);
V = A;
end UnitCheck13;
end unitCheckTests;
"); getErrorString();
setCommandLineOptions("--unitChecking -d=dumpUnits,newInst"); getErrorString();
instantiateModel(unitCheckTests.UnitCheck13); getErrorString();
// Result:
// true
// ""
// true
// ""
// HashTable:
// {V,{1.0 * m^(1)}}
// {A,{1.0 * m^(4)}}
// {S,{1.0 * m^(2)}}
// {jhagemann,{MASTER()}}
// ######## UnitCheck COMPLETED ########
// "class unitCheckTests.UnitCheck13
// Real V(unit = \"m\");
// Real A(unit = \"m4\");
// Real S(unit = \"m2\");
// equation
// A = 5.0;
// S = V ^ 2.0 + sqrt(A);
// V = A;
// end unitCheckTests.UnitCheck13;
// "
// "[<interactive>:10:5-10:10:writable] Warning: The following equation is INCONSISTENT due to specified unit information: V = A
// Warning: The units of following sub-expressions need to be equal:
// - sub-expression \"A\" has unit \"m4\"
// - sub-expression \"V\" has unit \"m\"
// Notification: \"V\" has the Unit \"m\"
// \"A\" has the Unit \"m4\"
// "
// endResult