Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2018-03-08 15:29:31 +0000
committerJuergen Haug2018-03-08 15:29:31 +0000
commit79aa00b074c61bde5173d4859ce2b52e50b52dec (patch)
tree2e0386f10deca9d07156e76d7a92ae029f0688b3 /tests/org.eclipse.etrice.generator.common.tests
parent588763d247c6132579eab3df528526e27c1e7f04 (diff)
downloadorg.eclipse.etrice-79aa00b074c61bde5173d4859ce2b52e50b52dec.tar.gz
org.eclipse.etrice-79aa00b074c61bde5173d4859ce2b52e50b52dec.tar.xz
org.eclipse.etrice-79aa00b074c61bde5173d4859ce2b52e50b52dec.zip
improved EnumTest
Diffstat (limited to 'tests/org.eclipse.etrice.generator.common.tests')
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/build.gradle9
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/CompileTests.room1
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/DetailExpressionTest.room22
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/EnumTest.room286
4 files changed, 255 insertions, 63 deletions
diff --git a/tests/org.eclipse.etrice.generator.common.tests/build.gradle b/tests/org.eclipse.etrice.generator.common.tests/build.gradle
index 7f797943e..8064212dd 100644
--- a/tests/org.eclipse.etrice.generator.common.tests/build.gradle
+++ b/tests/org.eclipse.etrice.generator.common.tests/build.gradle
@@ -12,8 +12,7 @@ def tests = [
choicePointTestExtended: ['models/ChoicePointTestExtended.room', genericPhysical],
dataDrivenTest: ['models/DataDrivenTest.room', genericPhysical],
/* enumTest: ['models/EnumTest.room', genericPhysical], not supported in c++ */
-
- compileTests: ['models/CompileTests.room', genericPhysical, 'models/DetailExpressionTest.room', 'models/DetailExpressionEnum.room', 'models/DetailExpressionTypes.room', 'models/StatemachineInterfaceTest.room', 'models/StatemachineInterfaceInheritedTest.room', 'models/StatemachineInterfaceTest.room', 'models/ContinuationTransitionTest.room'],
+ compileTests: ['models/CompileTests.room', genericPhysical, 'models/StatemachineInterfaceTest.room', 'models/StatemachineInterfaceInheritedTest.room', 'models/StatemachineInterfaceTest.room', 'models/ContinuationTransitionTest.room'],
handlerTest: ['models/HandlerTest.room', genericPhysical],
operationInheritanceTest: ['models/OperationInheritanceTest.room', genericPhysical],
@@ -29,4 +28,8 @@ tests.each { name, models ->
// Enum Test
createTest('c', 'enumTest', ['models/EnumTest.room', genericPhysical])
-createTest('java', 'enumTest', ['models/EnumTest.room', genericPhysical]) \ No newline at end of file
+createTest('java', 'enumTest', ['models/EnumTest.room', genericPhysical])
+
+// DetailExpressionCompile Test
+createTest('c', 'detailExpressionCompileTest', [genericPhysical, 'models/DetailExpressionTest.room', 'models/DetailExpressionEnum.room', 'models/DetailExpressionTypes.room'])
+createTest('java', 'detailExpressionCompileTest', [genericPhysical, 'models/DetailExpressionTest.room', 'models/DetailExpressionEnum.room', 'models/DetailExpressionTypes.room'])
diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/CompileTests.room b/tests/org.eclipse.etrice.generator.common.tests/models/CompileTests.room
index 2819b53fd..37698c77b 100644
--- a/tests/org.eclipse.etrice.generator.common.tests/models/CompileTests.room
+++ b/tests/org.eclipse.etrice.generator.common.tests/models/CompileTests.room
@@ -13,7 +13,6 @@ RoomModel CompileTests {
Attribute caseId : int32
// just compile
- ActorRef detailExpressionTest: DetailExpressionTest
ActorRef statemachineInterfaceTest : StatemachineInterfaceTest
ActorRef statemachineInterfaceInheritedTest : StatemachineInterfaceInheritedTest
ActorRef continuationTransitionTest : ContinuationTransitionTest
diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/DetailExpressionTest.room b/tests/org.eclipse.etrice.generator.common.tests/models/DetailExpressionTest.room
index 3fc01f00c..674799c82 100644
--- a/tests/org.eclipse.etrice.generator.common.tests/models/DetailExpressionTest.room
+++ b/tests/org.eclipse.etrice.generator.common.tests/models/DetailExpressionTest.room
@@ -2,9 +2,27 @@ RoomModel DetailExpressionTestModel {
import room.basic.types.* from "../../../runtime/${etModellib}/model/Types.room"
import room.basic.test.* from "../../../runtime/${etModellib}/model/Tests.room"
-// import room.basic.service.timing.* from "../../../runtime/${etModellib}/model/TimingService.room"
import DetailExpressionEnum.* from "DetailExpressionEnum.room"
-
+
+ ActorClass DetailExpressionCompileTest {
+ @TestInstance
+ Structure {
+ // just compile
+ ActorRef ref0 : DetailExpressionTest
+ Attribute caseId : int32
+ }
+ Behavior {
+ ctor '''caseId = etUnit_openAll("log", "DetailExpressionCompileTest", "org.eclipse.etrice.generator.common.tests.DetailExpressionCompileTest", "DetailExpressionCompileTest_case");'''
+ dtor '''etUnit_closeAll(caseId);'''
+ StateMachine {
+ Transition init: initial -> finish
+ State finish {
+ entry '''etUnit_testFinished(caseId);'''
+ }
+ }
+ }
+ }
+
Enumeration LocalEnum of int32 {
FIRST=1, SECOND=2, THIRD=3
}
diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/EnumTest.room b/tests/org.eclipse.etrice.generator.common.tests/models/EnumTest.room
index fa39886e8..97739a586 100644
--- a/tests/org.eclipse.etrice.generator.common.tests/models/EnumTest.room
+++ b/tests/org.eclipse.etrice.generator.common.tests/models/EnumTest.room
@@ -6,91 +6,263 @@ RoomModel EnumTest {
ActorClass EnumTest_Top {
@TestInstance
Structure {
- ActorRef user: EnumUser
+ ActorRef initTest: EnumInitialization
+ ActorRef translationTest: EnumTranslation
}
- Behavior { }
- }
-
- ActorClass EnumUser {
- Interface {
- Port prt: PC
+ Behavior {
}
+ }
+
+ ActorClass EnumInitialization {
Structure {
- external Port prt
-
Attribute caseId: int32
Attribute first: FirstEnum
Attribute second: SecondEnum = "two"
Attribute third: ThirdEnum
Attribute fourth: FourthEnum
Attribute fifth: FifthEnum
-
- Attribute arrayFirst[1] : FirstEnum
- Attribute arrayFourth[65] : FourthEnum = "sixtyfive"
- Attribute arrayFifth[2] : FifthEnum = "{f1, f2}"
-
+
+ Attribute arrayFirst [1]: FirstEnum
+ Attribute arrayFourth [65]: FourthEnum = "sixtyfive"
+ Attribute arrayFifth [2]: FifthEnum = "{f1, f2}"
}
Behavior {
- ctor {
- "caseId = etUnit_openAll(\"log\", \"EnumTest\", \"org.eclipse.etrice.generator.common.tests.EnumTest\", \"EnumTest_case\");"
- }
- dtor {
- "etUnit_closeAll(caseId);"
+ ctor '''
+ caseId = etUnit_openAll("log", "EnumTest", "org.eclipse.etrice.generator.common.tests.EnumTest", "EnumTest_case");
+ '''
+ dtor '''
+ etUnit_closeAll(caseId);
+ '''
+
+ StateMachine {
+ Transition init: initial -> attributeInit {
+ }
+ State attributeInit {
+ entry '''
+ EXPECT_EQUAL_INT32(caseId, "first: initialized value", 0, first);
+ EXPECT_EQUAL_INT32(caseId, "second: initialized value", 2, second);
+
+ EXPECT_EQUAL_INT32(caseId, "arrayFirst: initialized set value", 0, arrayFirst[0]);
+ EXPECT_EQUAL_INT32(caseId, "arrayFouth: initialized set value", 0x41, arrayFourth[20]);
+ EXPECT_EQUAL_INT16(caseId, "arrayFifth: initialized set value", (short)0x01, arrayFifth[0]);
+ EXPECT_EQUAL_INT16(caseId, "arrayFifth: initialized set value", (short)0x02, arrayFifth[1]);
+
+ first = FirstEnum.zero;
+ second = SecondEnum.three;
+ third = ThirdEnum.five;
+ fourth = FourthEnum.sixtyfive;
+ fifth = FifthEnum.f3;
+
+ EXPECT_EQUAL_INT32(caseId, "first: newly set value", 0, first);
+ EXPECT_EQUAL_INT32(caseId, "second: newly set value", 3, second);
+ EXPECT_EQUAL_INT32(caseId, "third: newly set value", 5, third);
+ EXPECT_EQUAL_INT32(caseId, "fourth: newly set value", 0x41, fourth);
+ EXPECT_EQUAL_INT16(caseId, "fifth: newly set value", (short)0x4, fifth);
+
+ etUnit_testFinished(caseId);
+ '''
+ }
}
+ }
+ }
+
+ Enumeration FirstEnum {
+ zero,
+ one,
+ two,
+ three
+ }
+
+ Enumeration SecondEnum {
+ one = 1,
+ two,
+ three
+ }
+
+ Enumeration ThirdEnum {
+ one = 1,
+ two,
+ five = 5
+ }
+
+ Enumeration FourthEnum {
+ one = 1,
+ three = 3,
+ sixtyfive = 0x41
+ }
+
+ Enumeration FifthEnum of int16 {
+ f1 = 0x1,
+ f2 = 0x2,
+ f3 = 0x4,
+ f4 = 0x8
+ }
+
+ ActorClass EnumTranslationBase {
+ Interface {
+ Port port: PEnum
+ }
+ Structure {
+ external Port port
+ Attribute attrEnum: AttributeEnum
+ Attribute attrData: DEnum
+ }
+ Behavior {
+ Operation enumOp(enumParam: OperationEnum): OperationEnum '''
+ return OperationEnum.zero;
+ '''
+ }
+ }
+
+ /**
+ * DetailCode place occurrences:
+ * - ActorClass: ctor/dtor, Operation, State(Entry/Do/Exit), Transition(Guard/Action/Condition)
+ * - DataClass: Operation
+ * - PortClass: Operation, handles
+ *
+ * Enum Providers:
+ * - ActorClass: Attribute, Operation, SPP/SAP/Ports
+ * - DataClass: Attribute, Operation
+ * - ProtocolClass: MessageData
+ * - PortClass: Attribute, Operation
+ *
+ * Inheritance: ActorClass, DataClass, ProtocolClass
+ *
+ */
+ ActorClass EnumTranslation extends EnumTranslationBase {
+ Behavior {
+ ctor '''
+ attrEnum = AttributeEnum.zero;
+ '''
StateMachine {
- Transition init: initial -> state0 { }
- State state0 {
- entry {
- "EXPECT_EQUAL_INT32(caseId, \"first: initialized value\", 0, first);"
- "EXPECT_EQUAL_INT32(caseId, \"second: initialized value\", 2, second);"
- ""
- "EXPECT_EQUAL_INT32(caseId, \"arrayFirst: initialized set value\", 0, arrayFirst[0]);"
- "EXPECT_EQUAL_INT32(caseId, \"arrayFouth: initialized set value\", 0x41, arrayFourth[20]);"
- "EXPECT_EQUAL_INT16(caseId, \"arrayFifth: initialized set value\", (short)0x01, arrayFifth[0]);"
- "EXPECT_EQUAL_INT16(caseId, \"arrayFifth: initialized set value\", (short)0x02, arrayFifth[1]);"
- ""
- "first = FirstEnum.zero;"
- "second = SecondEnum.three;"
- "third = ThirdEnum.five;"
- "fourth = FourthEnum.sixtyfive;"
- "fifth = FifthEnum.f3;"
- ""
- "EXPECT_EQUAL_INT32(caseId, \"first: newly set value\", 0, first);"
- "EXPECT_EQUAL_INT32(caseId, \"second: newly set value\", 3, second);"
- "EXPECT_EQUAL_INT32(caseId, \"third: newly set value\", 5, third);"
- "EXPECT_EQUAL_INT32(caseId, \"fourth: newly set value\", 0x41, fourth);"
- "EXPECT_EQUAL_INT16(caseId, \"fifth: newly set value\", (short)0x4, fifth);"
- ""
- "etUnit_testFinished(caseId);"
+ Transition init: initial -> state {
+ }
+ Transition enumTransition: state -> state {
+ triggers {
+ <enumIn: port guard '''transitionData == MessageEnum.zero'''>
}
+ action '''
+ // Attribute->Enum
+ attrEnum = AttributeEnum.zero;
+ // Operation->Enum
+ enumOp(OperationEnum.zero);
+ // Port->Message->Enum
+ port.enumOut(MessageEnum.zero);
+
+ // Port->Operation->Enum
+ /* port.enumOp(PortClassOperationEnum.zero); */
+
+ /*
+ DEnum attrDataClass;
+ // Attribute->DataClass->Enum
+ attrDataClass.enumAttr = DataClassEnum.zero;
+ // Attribute->DataClass->DataClass->Enum
+ attrDataClass.enumNested = NestedDataClassEnum.zero;
+ attrData = attrDataClass;
+
+ DMessageEnum messageDataClass;
+ // Port->Message->DataClass->Enum
+ messageDataClass.enumNested = MessageDataClassEnum.zero;
+ port.enumData(messageDataClass);
+ */
+ '''
}
+ State state
}
}
}
- ProtocolClass PC {
- incoming {
- Message m1(d: FirstEnum)
- }
+ // Operation->Enum
+ Enumeration OperationEnum {
+ zero
}
- Enumeration FirstEnum {
- zero, one, two, three
+ // Attribute->Enum
+ Enumeration AttributeEnum {
+ zero
}
- Enumeration SecondEnum {
- one=1, two, three
+ DataClass DEnumNested {
+ Attribute enumAttr: NestedDataClassEnum
}
- Enumeration ThirdEnum {
- one=1, two, five=5
+ DataClass DEnumBase {
+ Attribute enumAttr: DataClassEnum
+ Attribute enumNested: DEnumNested
+
+ Operation enumOp(enumPara: DataClassEnum) : DataClassEnum '''
+ /* enumNested.enumAttr = NestedDataClassEnum.zero; */
+
+ return DataClassEnum.zero;
+ '''
+ }
+
+ DataClass DEnum extends DEnumBase {
+ Attribute dummy: FirstEnum
}
- Enumeration FourthEnum {
- one=1, three=3, sixtyfive=0x41
+ // DataClass->Enum
+ Enumeration DataClassEnum {
+ zero
+ }
+
+ // DataClass->DataClass->Enum
+ Enumeration NestedDataClassEnum {
+ zero
}
- Enumeration FifthEnum of int16 {
- f1=0x1, f2=0x2, f3=0x4, f4=0x8
+ ProtocolClass PEnumBase {
+ incoming {
+ Message enumIn(MessageEnum)
+ }
+ outgoing {
+ Message enumOut(MessageEnum)
+ Message enumData(DMessageEnum)
+ }
+ regular PortClass
+ {
+ Attribute enumAttr: PortClassAttributeEnum
+
+ Operation enumOp(enumParam: PortClassOperationEnum): PortClassOperationEnum '''
+ enumAttr = PortClassAttributeEnum.zero;
+
+ return PortClassOperationEnum.zero;
+ '''
+ }
+ }
+
+ ProtocolClass PEnum extends PEnumBase {
+ outgoing {
+ Message handled(FirstEnum)
+ }
+ regular PortClass {
+ handle outgoing handled '''
+ /* enumAttr = PortClassAttributeEnum.zero; */
+ '''
+ }
+ }
+
+ // PortClass->Operation->Enum
+ Enumeration PortClassOperationEnum {
+ zero
+ }
+
+ // PortClass->Attribute->Enum
+ Enumeration PortClassAttributeEnum {
+ zero
+ }
+
+ // Message->Enum
+ Enumeration MessageEnum {
+ zero
+ }
+
+ // Message->DataClass->Enum
+ Enumeration MessageDataClassEnum {
+ zero
+ }
+
+ DataClass DMessageEnum {
+ Attribute enumAttr: MessageDataClassEnum
}
} \ No newline at end of file

Back to the top