Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/org.eclipse.etrice.generator.common.tests/drafts/OperationInheritance.room')
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/drafts/OperationInheritance.room126
1 files changed, 126 insertions, 0 deletions
diff --git a/tests/org.eclipse.etrice.generator.common.tests/drafts/OperationInheritance.room b/tests/org.eclipse.etrice.generator.common.tests/drafts/OperationInheritance.room
new file mode 100644
index 000000000..2ed4fe1fb
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.common.tests/drafts/OperationInheritance.room
@@ -0,0 +1,126 @@
+RoomModel OperationInheritance {
+
+ import room.basic.types.* from "../../org.eclipse.etrice.modellib.c/model/Types.room"
+
+ LogicalSystem OperationInheritanceSys {
+ SubSystemRef subSystemRef: OperationInheritanceSubSys
+ }
+
+ SubSystemClass OperationInheritanceSubSys {
+ ActorRef testActor: SubActor
+ LogicalThread defaultThread
+ }
+
+ ActorClass BaseActor {
+ Structure {
+ Attribute tcCaseId: 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(tcCaseId, \"<|MODEL_LOCATION|>\", true);"
+ }
+ Operation baseOperation() {
+ "valueBase = 1;"
+ }
+ }
+ }
+
+ ActorClass SubActor extends BaseActor {
+ Structure {
+ Attribute testDataClass: SubDataClass
+ }
+ Behavior {
+ ctor {
+ "etUnit_open(\"log\", \"OperationInheritance\");"
+ "etUnit_openTestSuite(\"OperationInheritanceSuite\");"
+ "tcCaseId = etUnit_openTestCase(\"OperationInheritanceTestCase\");"
+ "ctorRefine = 2;"
+ }
+ dtor {
+ "// sub dtor"
+ "etUnit_closeTestSuite();"
+ "etUnit_close();"
+ }
+ override Operation overriddenOperation() {
+ "valueSub = 2;"
+ }
+ StateMachine {
+ Transition init: initial -> state0 {
+ action {
+ "baseOperation();"
+ "overriddenOperation();"
+ // c: not supported yet
+ //"testDataClass.baseOperation();"
+ //"testDataClass.overriddenOperation(tcCaseId);"
+ }
+ }
+ State state0 {
+ entry {
+ "// refine ctor, override operations"
+ "// -- ActorClass"
+ "EXPECT_EQUAL_INT32(tcCaseId, \"<|MODEL_LOCATION|>\", 1, ctorBase);"
+ "EXPECT_EQUAL_INT32(tcCaseId, \"<|MODEL_LOCATION|>\", 2, ctorRefine);"
+ "EXPECT_EQUAL_INT32(tcCaseId, \"<|MODEL_LOCATION|>\", 1, valueBase);"
+ "EXPECT_EQUAL_INT32(tcCaseId, \"<|MODEL_LOCATION|>\", 2, valueSub);"
+ ""
+ "// -- DataClass"
+ // c: not supported yet
+ //"EXPECT_EQUAL_INT32(tcCaseId, \"<|MODEL_LOCATION|>\", 1, testDataClass.ctorBase);"
+ //"EXPECT_EQUAL_INT32(tcCaseId, \"<|MODEL_LOCATION|>\", 2, testDataClass.ctorRefine);"
+ //"EXPECT_EQUAL_INT32(tcCaseId, \"<|MODEL_LOCATION|>\", 1, testDataClass.valueBase);"
+ //"EXPECT_EQUAL_INT32(tcCaseId, \"<|MODEL_LOCATION|>\", 2, testDataClass.valueSub);"
+ //"EXPECT_EQUAL_INT32(tcCaseId, \"<|MODEL_LOCATION|>\", 0, testDataClass.doNotCallOverride);"
+ ""
+ "etUnit_closeTestCase(tcCaseId);"
+ "etUnit_testFinished(tcCaseId);"
+ }
+ }
+ }
+ }
+ }
+
+ DataClass BaseDataClass {
+ Attribute ctorBase: int32 = "0"
+ Attribute ctorRefine: int32 = "0"
+ Attribute valueBase: int32 = "0"
+ Attribute valueSub: int32 = "0"
+ Attribute doNotCallOverride : int32 = "0"
+ ctor {
+ "ctorBase = 1;"
+ "ctorRefine = 1;"
+ }
+ dtor {
+ "// base dtor"
+ }
+ Operation overriddenOperation() {
+ "doNotCallOverride = 1;"
+ }
+ Operation baseOperation() {
+ "valueBase = 1;"
+ }
+ }
+
+ DataClass SubDataClass extends BaseDataClass {
+ ctor {
+ "ctorRefine = 2;"
+ }
+ dtor {
+ "// sub dtor"
+ }
+ override Operation overriddenOperation() {
+ "valueSub = 2;"
+ }
+ }
+
+} \ No newline at end of file

Back to the top