| RoomModel OperationInheritanceTest { |
| |
| import room.basic.types.int32 |
| import room.basic.test.TestInstance |
| |
| async ActorClass OperationInheritanceTest extends BaseActor { |
| @TestInstance |
| Structure { |
| Attribute testDataClass: SubDataClass |
| } |
| Behavior { |
| ctor ''' |
| caseId = etUnit_openAll("log", "OperationInheritanceTest", "org.eclipse.etrice.generator.common.tests.OperationInheritanceTest", "OperationInheritanceTest_case"); |
| ctorRefine = 2;''' |
| dtor ''' |
| // sub dtor |
| etUnit_closeAll(caseId);''' |
| override Operation overriddenOperation() '''valueSub = 2;''' |
| StateMachine { |
| Transition init: initial -> finish { |
| action ''' |
| baseOperation(); |
| overriddenOperation(); |
| // c: not supported in detail code translator |
| //testDataClass.baseOperation(); |
| //testDataClass.overriddenOperation(); |
| |
| // refine ctor, override operations |
| // -- ActorClass |
| EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 1, ctorBase); |
| EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 2, ctorRefine); |
| EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 1, valueBase); |
| EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 2, valueSub); |
| |
| // -- DataClass |
| // cannot work due missing calls, see above |
| //EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 1, testDataClass.ctorBase_); |
| //EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 2, testDataClass.ctorRefine_); |
| //EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 1, testDataClass.valueBase_); |
| //EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 2, testDataClass.valueSub_); |
| //EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 0, testDataClass.doNotCallOverride_); |
| etUnit_testFinished(caseId);''' |
| } |
| State finish |
| } |
| } |
| } |
| |
| abstract async ActorClass BaseActor { |
| Structure { |
| Attribute caseId: int32 |
| Attribute ctorBase: int32 = "0" |
| Attribute ctorRefine: int32 = "0" |
| Attribute valueBase: int32 = "0" |
| Attribute valueSub: int32 = "0" |
| } |
| Behavior { |
| ctor ''' |
| ctorBase = 1; |
| ctorRefine = 1;''' |
| dtor '''// base dtor''' |
| Operation overriddenOperation() '''EXPECT_FALSE(caseId, "<|MODEL_LOCATION|>", true);''' |
| Operation baseOperation() '''valueBase = 1;''' |
| } |
| } |
| |
| /** the suffix '_' is necessary for C due macros :( */ |
| DataClass BaseDataClass { |
| Operation overriddenOperation() '''doNotCallOverride_ = 1;''' |
| Operation baseOperation() '''valueBase_ = 1;''' |
| ctor ''' |
| ctorBase_ = 1; |
| ctorRefine_ = 1;''' |
| Attribute ctorBase_: int32 = "0" |
| Attribute ctorRefine_: int32 = "0" |
| Attribute valueBase_: int32 = "0" |
| Attribute valueSub_: int32 = "0" |
| Attribute doNotCallOverride_: int32 = "0" |
| } |
| |
| DataClass SubDataClass extends BaseDataClass { |
| override Operation overriddenOperation() '''valueSub_ = 2;''' |
| ctor '''ctorRefine_ = 2;''' |
| } |
| } |