Browse Source

added sctunit test and elaborated test cart for issue #355

Axel Terfloth 9 years ago
parent
commit
7c3634381c

+ 16 - 47
test-plugins/org.yakindu.sct.test.models/testmodels/SCTUnit/expressions/TriggerExpressionPrecedence.sct

@@ -1,16 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:sgraph="http://www.yakindu.org/sct/sgraph/2.0.0">
-  <sgraph:Statechart xmi:id="_eGVTMM51EeWP64SB222YgA" specification="namespace expressions&#xA;&#xA;interface:&#xA;&#xA;in event toB&#xA;in event toC&#xA;&#xA;var c1 : boolean&#xA;var c2 : boolean&#xA;&#xA;&#xA;internal:" namespace="expressions" name="TriggerExpressionPrecedence">
+  <sgraph:Statechart xmi:id="_eGVTMM51EeWP64SB222YgA" specification="namespace expressions&#xA;&#xA;interface:&#xA;&#xA;in event e1&#xA;in event e2&#xA;&#xA;var c1 : boolean&#xA;var c2 : boolean&#xA;&#xA;&#xA;var e1_transition : boolean&#xA;var e2_transition : boolean&#xA;&#xA;" namespace="expressions" name="TriggerExpressionPrecedence">
     <regions xmi:id="_eGtGoM51EeWP64SB222YgA" name="main region">
       <vertices xsi:type="sgraph:Entry" xmi:id="_eHABkM51EeWP64SB222YgA">
         <outgoingTransitions xmi:id="_eHH9YM51EeWP64SB222YgA" target="_eHB2wM51EeWP64SB222YgA"/>
       </vertices>
-      <vertices xsi:type="sgraph:State" xmi:id="_eHB2wM51EeWP64SB222YgA" name="A" incomingTransitions="_eHH9YM51EeWP64SB222YgA">
-        <outgoingTransitions xmi:id="_xjIDEM51EeWP64SB222YgA" specification="toB [c1 || c2]" target="_xjAuUM51EeWP64SB222YgA"/>
-        <outgoingTransitions xmi:id="_y-GzUM51EeWP64SB222YgA" specification="toC" target="_y9_ekM51EeWP64SB222YgA"/>
+      <vertices xsi:type="sgraph:State" xmi:id="_eHB2wM51EeWP64SB222YgA" name="A" incomingTransitions="_eHH9YM51EeWP64SB222YgA _xjIDEM51EeWP64SB222YgA _y-GzUM51EeWP64SB222YgA">
+        <outgoingTransitions xmi:id="_xjIDEM51EeWP64SB222YgA" specification="e1 [c1 || c2] / e1_transition = true" target="_eHB2wM51EeWP64SB222YgA"/>
+        <outgoingTransitions xmi:id="_y-GzUM51EeWP64SB222YgA" specification="e2 / e2_transition = true" target="_eHB2wM51EeWP64SB222YgA"/>
       </vertices>
-      <vertices xsi:type="sgraph:State" xmi:id="_xjAuUM51EeWP64SB222YgA" name="B" incomingTransitions="_xjIDEM51EeWP64SB222YgA"/>
-      <vertices xsi:type="sgraph:State" xmi:id="_y9_ekM51EeWP64SB222YgA" name="C" incomingTransitions="_y-GzUM51EeWP64SB222YgA"/>
     </regions>
   </sgraph:Statechart>
   <notation:Diagram xmi:id="_eGsfkM51EeWP64SB222YgA" type="org.yakindu.sct.ui.editor.editor.StatechartDiagramEditor" element="_eGVTMM51EeWP64SB222YgA" measurementUnit="Pixel">
@@ -47,39 +45,7 @@
           <styles xsi:type="notation:ShapeStyle" xmi:id="_eHE6Ec51EeWP64SB222YgA" fontName="Verdana" fillColor="15981773" lineColor="12632256"/>
           <styles xsi:type="notation:FontStyle" xmi:id="_eHE6Es51EeWP64SB222YgA"/>
           <styles xsi:type="notation:BooleanValueStyle" xmi:id="_eHGvQc51EeWP64SB222YgA" name="isHorizontal" booleanValue="true"/>
-          <layoutConstraint xsi:type="notation:Bounds" xmi:id="_eHGvQs51EeWP64SB222YgA" x="50" y="61"/>
-        </children>
-        <children xmi:id="_xjB8cM51EeWP64SB222YgA" type="State" element="_xjAuUM51EeWP64SB222YgA">
-          <children xsi:type="notation:DecorationNode" xmi:id="_xjCjgM51EeWP64SB222YgA" type="StateName">
-            <styles xsi:type="notation:ShapeStyle" xmi:id="_xjCjgc51EeWP64SB222YgA"/>
-            <layoutConstraint xsi:type="notation:Location" xmi:id="_xjCjgs51EeWP64SB222YgA"/>
-          </children>
-          <children xsi:type="notation:Compartment" xmi:id="_xjCjg851EeWP64SB222YgA" type="StateTextCompartment">
-            <children xsi:type="notation:Shape" xmi:id="_xjDKkM51EeWP64SB222YgA" type="StateTextCompartmentExpression" fontName="Verdana" lineColor="4210752">
-              <layoutConstraint xsi:type="notation:Bounds" xmi:id="_xjDKkc51EeWP64SB222YgA"/>
-            </children>
-          </children>
-          <children xsi:type="notation:Compartment" xmi:id="_xjDKks51EeWP64SB222YgA" type="StateFigureCompartment"/>
-          <styles xsi:type="notation:ShapeStyle" xmi:id="_xjB8cc51EeWP64SB222YgA" fontName="Verdana" fillColor="15981773" lineColor="12632256"/>
-          <styles xsi:type="notation:FontStyle" xmi:id="_xjB8cs51EeWP64SB222YgA"/>
-          <styles xsi:type="notation:BooleanValueStyle" xmi:id="_xjDKk851EeWP64SB222YgA" name="isHorizontal" booleanValue="true"/>
-          <layoutConstraint xsi:type="notation:Bounds" xmi:id="_xjB8c851EeWP64SB222YgA" x="209" y="61"/>
-        </children>
-        <children xmi:id="_y-AssM51EeWP64SB222YgA" type="State" element="_y9_ekM51EeWP64SB222YgA">
-          <children xsi:type="notation:DecorationNode" xmi:id="_y-BTwM51EeWP64SB222YgA" type="StateName">
-            <styles xsi:type="notation:ShapeStyle" xmi:id="_y-BTwc51EeWP64SB222YgA"/>
-            <layoutConstraint xsi:type="notation:Location" xmi:id="_y-BTws51EeWP64SB222YgA"/>
-          </children>
-          <children xsi:type="notation:Compartment" xmi:id="_y-B60M51EeWP64SB222YgA" type="StateTextCompartment">
-            <children xsi:type="notation:Shape" xmi:id="_y-B60c51EeWP64SB222YgA" type="StateTextCompartmentExpression" fontName="Verdana" lineColor="4210752">
-              <layoutConstraint xsi:type="notation:Bounds" xmi:id="_y-B60s51EeWP64SB222YgA"/>
-            </children>
-          </children>
-          <children xsi:type="notation:Compartment" xmi:id="_y-B60851EeWP64SB222YgA" type="StateFigureCompartment"/>
-          <styles xsi:type="notation:ShapeStyle" xmi:id="_y-Assc51EeWP64SB222YgA" fontName="Verdana" fillColor="15981773" lineColor="12632256"/>
-          <styles xsi:type="notation:FontStyle" xmi:id="_y-Asss51EeWP64SB222YgA"/>
-          <styles xsi:type="notation:BooleanValueStyle" xmi:id="_y-B61M51EeWP64SB222YgA" name="isHorizontal" booleanValue="true"/>
-          <layoutConstraint xsi:type="notation:Bounds" xmi:id="_y-Ass851EeWP64SB222YgA" x="50" y="191"/>
+          <layoutConstraint xsi:type="notation:Bounds" xmi:id="_eHGvQs51EeWP64SB222YgA" x="50" y="61" height="114"/>
         </children>
         <layoutConstraint xsi:type="notation:Bounds" xmi:id="_eG9lUc51EeWP64SB222YgA"/>
       </children>
@@ -106,23 +72,26 @@
       <styles xsi:type="notation:FontStyle" xmi:id="_eHNc8s51EeWP64SB222YgA" fontName="Verdana"/>
       <bendpoints xsi:type="notation:RelativeBendpoints" xmi:id="_eHNc8c51EeWP64SB222YgA" points="[0, 0, 0, 0]$[0, 0, 0, 0]"/>
     </edges>
-    <edges xmi:id="_xjJRMM51EeWP64SB222YgA" type="Transition" element="_xjIDEM51EeWP64SB222YgA" source="_eHE6EM51EeWP64SB222YgA" target="_xjB8cM51EeWP64SB222YgA">
+    <edges xmi:id="_xjJRMM51EeWP64SB222YgA" type="Transition" element="_xjIDEM51EeWP64SB222YgA" source="_eHE6EM51EeWP64SB222YgA" target="_eHE6EM51EeWP64SB222YgA">
       <children xsi:type="notation:DecorationNode" xmi:id="_xjM7kc51EeWP64SB222YgA" type="TransitionExpression">
         <styles xsi:type="notation:ShapeStyle" xmi:id="_xjM7ks51EeWP64SB222YgA"/>
-        <layoutConstraint xsi:type="notation:Location" xmi:id="_xjM7k851EeWP64SB222YgA" y="10"/>
+        <layoutConstraint xsi:type="notation:Location" xmi:id="_xjM7k851EeWP64SB222YgA" x="-2" y="-93"/>
       </children>
-      <styles xsi:type="notation:ConnectorStyle" xmi:id="_xjJRMc51EeWP64SB222YgA" lineColor="4210752"/>
+      <styles xsi:type="notation:ConnectorStyle" xmi:id="_xjJRMc51EeWP64SB222YgA" routing="Rectilinear" lineColor="4210752"/>
       <styles xsi:type="notation:FontStyle" xmi:id="_xjM7kM51EeWP64SB222YgA" fontName="Verdana"/>
-      <bendpoints xsi:type="notation:RelativeBendpoints" xmi:id="_xjJRMs51EeWP64SB222YgA" points="[-17, -22, 53, 66]$[-68, -85, 2, 3]"/>
+      <bendpoints xsi:type="notation:RelativeBendpoints" xmi:id="_xjJRMs51EeWP64SB222YgA" points="[13, 0, 7, -5]$[109, 0, 103, -5]$[109, 14, 103, 9]$[13, 14, 7, 9]"/>
+      <sourceAnchor xsi:type="notation:IdentityAnchor" xmi:id="_TQhUgM6nEeWP64SB222YgA" id="(0.65,0.20754716981132076)"/>
+      <targetAnchor xsi:type="notation:IdentityAnchor" xmi:id="_STENwM6nEeWP64SB222YgA" id="(0.8,0.3018867924528302)"/>
     </edges>
-    <edges xmi:id="_y-HaYM51EeWP64SB222YgA" type="Transition" element="_y-GzUM51EeWP64SB222YgA" source="_eHE6EM51EeWP64SB222YgA" target="_y-AssM51EeWP64SB222YgA">
+    <edges xmi:id="_y-HaYM51EeWP64SB222YgA" type="Transition" element="_y-GzUM51EeWP64SB222YgA" source="_eHE6EM51EeWP64SB222YgA" target="_eHE6EM51EeWP64SB222YgA">
       <children xsi:type="notation:DecorationNode" xmi:id="_y-IBcM51EeWP64SB222YgA" type="TransitionExpression">
         <styles xsi:type="notation:ShapeStyle" xmi:id="_y-IBcc51EeWP64SB222YgA"/>
-        <layoutConstraint xsi:type="notation:Location" xmi:id="_y-IBcs51EeWP64SB222YgA" x="-3" y="18"/>
+        <layoutConstraint xsi:type="notation:Location" xmi:id="_y-IBcs51EeWP64SB222YgA" x="-1" y="-73"/>
       </children>
-      <styles xsi:type="notation:ConnectorStyle" xmi:id="_y-HaYc51EeWP64SB222YgA" lineColor="4210752"/>
+      <styles xsi:type="notation:ConnectorStyle" xmi:id="_y-HaYc51EeWP64SB222YgA" routing="Rectilinear" lineColor="4210752"/>
       <styles xsi:type="notation:FontStyle" xmi:id="_y-HaY851EeWP64SB222YgA" fontName="Verdana"/>
-      <bendpoints xsi:type="notation:RelativeBendpoints" xmi:id="_y-HaYs51EeWP64SB222YgA" points="[-17, -22, 53, 66]$[-68, -85, 2, 3]"/>
+      <bendpoints xsi:type="notation:RelativeBendpoints" xmi:id="_y-HaYs51EeWP64SB222YgA" points="[18, 0, 16, -35]$[110, 0, 108, -35]$[110, 18, 108, -17]$[18, 18, 16, -17]"/>
+      <targetAnchor xsi:type="notation:IdentityAnchor" xmi:id="_aQ0ugM6nEeWP64SB222YgA" id="(0.55,0.8245614035087719)"/>
     </edges>
   </notation:Diagram>
 </xmi:XMI>

+ 1 - 0
test-plugins/org.yakindu.sct.test.models/tests/AllTests.sctunit

@@ -54,5 +54,6 @@ testsuite AllTests {
 	SyncJoin, 
 	TransitionWithoutCondition,
 	TriggerGuardExpressions,
+	TriggerExpressionPrecedence,
 	ValuedEvents
 } 

+ 64 - 0
test-plugins/org.yakindu.sct.test.models/tests/expressions/TriggerExpressionPrecedence.sctunit

@@ -0,0 +1,64 @@
+/**
+ * These test cases check the precedence issues that occured with the construction of the trigger condition 
+ * that consists of the trigger and guard part. 
+ * The condition for a local reaction and transition depends on the trigger and guard part.
+ */
+testgroup TriggerExpressionPrecedence for statechart expressions.TriggerExpressionPrecedence {
+	
+	
+	/** If a trigger is specified and not active then the trigger condition should not become true. */
+	test unsatisfiedTriggerAndFGuardFalseOrFalse {
+
+		enter
+		
+		c1 = false
+		c2 = false
+		
+		cycle
+		
+		assert ! e1_transition
+	}
+
+
+	/** If a trigger is specified and not active then the trigger condition should not become true. */
+	test unsatisfiedTriggerAndFGuardTrueOrFalse {
+
+		enter
+		
+		c1 = true
+		c2 = false
+		
+		cycle
+		
+		assert ! e1_transition
+	}
+
+
+	/** If a trigger is specified and not active then the trigger condition should not become true. */
+	test unsatisfiedTriggerAndFGuardFalseOrTrue {
+
+		enter
+		
+		c1 = false
+		c2 = true
+		
+		cycle
+		
+		assert ! e1_transition
+	}
+
+
+	/** If a trigger is specified and not active then the trigger condition should not become true. */
+	test unsatisfiedTriggerAndFGuardTrueOrTrue {
+
+		enter
+		
+		c1 = true
+		c2 = true
+		
+		cycle
+		
+		assert ! e1_transition
+	}
+}
+