Skip to content

Commit

Permalink
Updated nfinst test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
perost authored and OpenModelica-Hudson committed Oct 4, 2017
1 parent a3201a2 commit 1cd286d
Show file tree
Hide file tree
Showing 27 changed files with 761 additions and 30 deletions.
28 changes: 28 additions & 0 deletions flattening/modelica/scodeinst/ExtendInherited1.mo
@@ -0,0 +1,28 @@
// name: ExtendsInherited1
// keywords:
// status: incorrect
// cflags: -d=newInst
//

model A
Real x;

model A
Real x;
end A;
end A;

model ExtendsInherited1
extends A;
end ExtendsInherited1;

// Result:
// Error processing file: ExtendInherited1.mo
// [flattening/modelica/scodeinst/ExtendInherited1.mo:16:3-16:12:writable] Notification: From here:
// [flattening/modelica/scodeinst/ExtendInherited1.mo:10:3-12:8:writable] Error: Found other base class for extends A after instantiating extends.
//
// # Error encountered! Exiting...
// # Please check the error message and the flags.
//
// Execution failed!
// endResult
28 changes: 28 additions & 0 deletions flattening/modelica/scodeinst/InnerOuter1.mo
@@ -0,0 +1,28 @@
// name: InnerOuter1
// keywords:
// status: correct
// cflags: -d=newInst
//

model A
outer Real x;
Real y;
equation
y = x;
end A;

model InnerOuter1
inner Real x = 1.0;
A a1, a2;
end InnerOuter1;

// Result:
// class InnerOuter1
// Real x = 1.0;
// Real a1.y;
// Real a2.y;
// equation
// a1.y = x;
// a2.y = x;
// end InnerOuter1;
// endResult
81 changes: 81 additions & 0 deletions flattening/modelica/scodeinst/InnerOuter2.mo
@@ -0,0 +1,81 @@
// name: InnerOuter2
// keywords:
// status: correct
// cflags: -d=newInst
//
// inner/outer example from the specification.
//

class A
class B
class C
class D
outer Real TI;
end D;

Real TI;
D d;
end C;

Real TI;
C c;
end B;

outer Real TI;
B b;
end A;

class E
class F
class G
class H
A a;
end H;

Real TI;
H h;
end G;

inner Real TI;
G g;
end F;

inner Real TI;
F f;
end E;

class I
inner Real TI;
E e;
A a;
end I;

// Result:
// class I
// Real TI;
// Real e.TI;
// Real e.f.TI;
// Real e.f.g.TI;
// Real e.f.g.h.a.b.TI;
// Real e.f.g.h.a.b.c.TI;
// Real a.b.TI;
// Real a.b.c.TI;
// end I;
// [flattening/modelica/scodeinst/InnerOuter2.mo:13:9-13:22:writable] Notification: From here:
// [flattening/modelica/scodeinst/InnerOuter2.mo:16:7-16:14:writable] Warning: Ignoring non-inner TI when looking for inner.
// [flattening/modelica/scodeinst/InnerOuter2.mo:13:9-13:22:writable] Notification: From here:
// [flattening/modelica/scodeinst/InnerOuter2.mo:20:5-20:12:writable] Warning: Ignoring non-inner TI when looking for inner.
// [flattening/modelica/scodeinst/InnerOuter2.mo:13:9-13:22:writable] Notification: From here:
// [flattening/modelica/scodeinst/InnerOuter2.mo:24:3-24:16:writable] Warning: Ignoring non-inner TI when looking for inner.
// [flattening/modelica/scodeinst/InnerOuter2.mo:24:3-24:16:writable] Notification: From here:
// [flattening/modelica/scodeinst/InnerOuter2.mo:35:7-35:14:writable] Warning: Ignoring non-inner TI when looking for inner.
// [flattening/modelica/scodeinst/InnerOuter2.mo:13:9-13:22:writable] Notification: From here:
// [flattening/modelica/scodeinst/InnerOuter2.mo:16:7-16:14:writable] Warning: Ignoring non-inner TI when looking for inner.
// [flattening/modelica/scodeinst/InnerOuter2.mo:13:9-13:22:writable] Notification: From here:
// [flattening/modelica/scodeinst/InnerOuter2.mo:20:5-20:12:writable] Warning: Ignoring non-inner TI when looking for inner.
// [flattening/modelica/scodeinst/InnerOuter2.mo:13:9-13:22:writable] Notification: From here:
// [flattening/modelica/scodeinst/InnerOuter2.mo:24:3-24:16:writable] Warning: Ignoring non-inner TI when looking for inner.
// [flattening/modelica/scodeinst/InnerOuter2.mo:13:9-13:22:writable] Notification: From here:
// [flattening/modelica/scodeinst/InnerOuter2.mo:35:7-35:14:writable] Warning: Ignoring non-inner TI when looking for inner.
//
// endResult
39 changes: 39 additions & 0 deletions flattening/modelica/scodeinst/InnerOuter3.mo
@@ -0,0 +1,39 @@
// name: InnerOuter3
// keywords:
// status: correct
// cflags: -d=newInst
//
// inner/outer example from the specification.
//

model ConditionalIntegrator
outer Boolean isEnabled;
Real x(start=1);
equation
der(x)=if isEnabled then (-x) else 0;
end ConditionalIntegrator;

model SubSystem
Boolean enableMe = time<=1;
inner outer Boolean isEnabled = isEnabled and enableMe;
ConditionalIntegrator conditionalIntegrator;
ConditionalIntegrator conditionalIntegrator2;
end SubSystem;

model InnerOuter3
SubSystem subSystem;
inner Boolean isEnabled = time>=0.5;
end InnerOuter3;

// Result:
// class InnerOuter3
// Boolean subSystem.enableMe = time <= 1.0;
// Boolean subSystem.isEnabled = isEnabled and subSystem.enableMe;
// Real subSystem.conditionalIntegrator.x(start = 1);
// Real subSystem.conditionalIntegrator2.x(start = 1);
// Boolean isEnabled = time >= 0.5;
// equation
// der(subSystem.conditionalIntegrator.x) = if subSystem.isEnabled then -subSystem.conditionalIntegrator.x else 0.0;
// der(subSystem.conditionalIntegrator2.x) = if subSystem.isEnabled then -subSystem.conditionalIntegrator2.x else 0.0;
// end InnerOuter3;
// endResult
30 changes: 30 additions & 0 deletions flattening/modelica/scodeinst/InnerOuter4.mo
@@ -0,0 +1,30 @@
// name: InnerOuter4
// keywords:
// status: correct
// cflags: -d=newInst
//

model A
outer Real x;
Real y;
equation
y = x;
end A;

model B
A a;
end B;

model InnerOuter4
inner Real x = 1.0;
B b;
end InnerOuter4;

// Result:
// class InnerOuter4
// Real x = 1.0;
// Real b.a.y;
// equation
// b.a.y = x;
// end InnerOuter4;
// endResult
34 changes: 34 additions & 0 deletions flattening/modelica/scodeinst/InnerOuter5.mo
@@ -0,0 +1,34 @@
// name: InnerOuter5
// keywords:
// status: correct
// cflags: -d=newInst
//

model A
Real x;
end A;

model B
outer A a;
Real y;
equation
y = a.x;
end B;

model C
B b;
end C;

model InnerOuter5
inner A a(x = 1.0);
C c;
end InnerOuter5;

// Result:
// class InnerOuter5
// Real a.x = 1.0;
// Real c.b.y;
// equation
// c.b.y = a.x;
// end InnerOuter5;
// endResult
31 changes: 31 additions & 0 deletions flattening/modelica/scodeinst/InnerOuterClass1.mo
@@ -0,0 +1,31 @@
// name: InnerOuterClass1
// keywords:
// status: correct
// cflags: -d=newInst
//

model A
Real x;
end A;

model B
Real x;
Real y;
end B;

model C
outer model M = A;
M m;
end C;

model D
inner model M = B;
C c;
end D;

// Result:
// class D
// Real c.m.x;
// Real c.m.y;
// end D;
// endResult
29 changes: 29 additions & 0 deletions flattening/modelica/scodeinst/InnerOuterExtends1.mo
@@ -0,0 +1,29 @@
// name: InnerOuterExtends1
// keywords:
// status: correct
// cflags: -d=newInst
//

model A
outer model M = B;
extends M;
end A;

model B
Real x;
end B;

model C
Real x = 1.0;
end C;

model InnerOuterExtends1
A a;
inner model M = C;
end InnerOuterExtends1;

// Result:
// class InnerOuterExtends1
// Real a.x = 1.0;
// end InnerOuterExtends1;
// endResult
24 changes: 24 additions & 0 deletions flattening/modelica/scodeinst/InnerOuterInvalidMod1.mo
@@ -0,0 +1,24 @@
// name: InnerOuterInvalidMod1
// keywords:
// status: incorrect
// cflags: -d=newInst
//

model A
outer Real x = 1.0;
end A;

model InnerOuterInvalidMod1
inner Real x = 2.0;
A a;
end InnerOuterInvalidMod1;

// Result:
// Error processing file: InnerOuterInvalidMod1.mo
// [flattening/modelica/scodeinst/InnerOuterInvalidMod1.mo:8:3-8:21:writable] Error: Modifier '= 1.0' found on outer element x.
//
// # Error encountered! Exiting...
// # Please check the error message and the flags.
//
// Execution failed!
// endResult
24 changes: 24 additions & 0 deletions flattening/modelica/scodeinst/InnerOuterInvalidMod2.mo
@@ -0,0 +1,24 @@
// name: InnerOuterInvalidMod2
// keywords:
// status: incorrect
// cflags: -d=newInst
//

model A
outer Real x;
end A;

model InnerOuterInvalidMod2
inner Real x = 2.0;
A a(x = 1.0);
end InnerOuterInvalidMod2;

// Result:
// Error processing file: InnerOuterInvalidMod2.mo
// [flattening/modelica/scodeinst/InnerOuterInvalidMod2.mo:8:3-8:15:writable] Error: Modifier '= 1.0' found on outer element x.
//
// # Error encountered! Exiting...
// # Please check the error message and the flags.
//
// Execution failed!
// endResult
24 changes: 24 additions & 0 deletions flattening/modelica/scodeinst/InnerOuterInvalidMod3.mo
@@ -0,0 +1,24 @@
// name: InnerOuterInvalidMod3
// keywords:
// status: incorrect
// cflags: -d=newInst
//

model A
outer replaceable Real x;
end A;

model InnerOuterInvalidMod3
inner Real x = 2.0;
A a(redeclare Real x = 1.0);
end InnerOuterInvalidMod3;

// Result:
// Error processing file: InnerOuterInvalidMod3.mo
// [flattening/modelica/scodeinst/InnerOuterInvalidMod3.mo:8:3-8:27:writable] Error: Modifier 'redeclare Real x = 1.0' found on outer element x.
//
// # Error encountered! Exiting...
// # Please check the error message and the flags.
//
// Execution failed!
// endResult

0 comments on commit 1cd286d

Please sign in to comment.