소스 검색

added tests for HexLiteral and Final State

malknet42 11 년 전
부모
커밋
b845caf3f8
14개의 변경된 파일234개의 추가작업 그리고 152개의 파일을 삭제
  1. 2 0
      test-plugins/org.yakindu.sct.generator.c.test/gtests/SimpleEvent/SimpleEvent.cc
  2. 8 8
      test-plugins/org.yakindu.sct.generator.cpp.test/gtests/SimpleEventTest/SimpleEvent.sgen
  3. 27 25
      test-plugins/org.yakindu.sct.generator.cpp.test/gtests/SimpleEventTest/SimpleEventTest.cc
  4. 39 39
      test-plugins/org.yakindu.sct.generator.cpp.test/test-gen/org/yakindu/sct/generator/cpp/test/SimpleEventTest.java
  5. 34 0
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/declarations/DeclarationsStatemachine.java
  6. 4 0
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/declarations/IDeclarationsStatemachine.java
  7. 20 1
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/simpleevent/SimpleEventStatemachine.java
  8. 3 1
      test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/SimpleEventTest.java
  9. 2 0
      test-plugins/org.yakindu.sct.simulation.core.sexec.test/test-gen/org/yakindu/sct/simulation/core/sexec/test/SimpleEventTest.java
  10. 72 72
      test-plugins/org.yakindu.sct.test.models/testmodels/SCTUnit/Declarations.sct
  11. 4 4
      test-plugins/org.yakindu.sct.test.models/testmodels/SCTUnit/JavaKeywords.sct
  12. 16 1
      test-plugins/org.yakindu.sct.test.models/testmodels/SCTUnit/SimpleEvent.sct
  13. 0 1
      test-plugins/org.yakindu.sct.test.models/tests/Declarations.sctunit
  14. 3 0
      test-plugins/org.yakindu.sct.test.models/tests/SimpleEvent.sctunit

+ 2 - 0
test-plugins/org.yakindu.sct.generator.c.test/gtests/SimpleEvent/SimpleEvent.cc

@@ -23,6 +23,8 @@ TEST(StatemachineTest, simpleEventTest) {
 	simpleEventIface_raise_event1(&handle);
 	simpleEvent_runCycle(&handle);
 	EXPECT_TRUE(simpleEvent_isActive(&handle, SimpleEvent_B)) << "Expected B to be active" ;
+	simpleEvent_runCycle(&handle);
+	EXPECT_TRUE(!simpleEvent_isActive(&handle, SimpleEvent_B));
 }
 
 		

+ 8 - 8
test-plugins/org.yakindu.sct.generator.cpp.test/gtests/SimpleEventTest/SimpleEvent.sgen

@@ -1,8 +1,8 @@
-GeneratorModel for yakindu::cpp {
-	statechart SimpleEvent {
-		feature Outlet {
-			targetProject = "gtests"
-			targetFolder = "SimpleEventTest"
-		}
-	}
-}
+GeneratorModel for yakindu::cpp {
+	statechart SimpleEvent {
+		feature Outlet {
+			targetProject = "gtests"
+			targetFolder = "SimpleEventTest"
+		}
+	}
+}

+ 27 - 25
test-plugins/org.yakindu.sct.generator.cpp.test/gtests/SimpleEventTest/SimpleEventTest.cc

@@ -1,25 +1,27 @@
-/**
-* Copyright (c) 2014 committers of YAKINDU and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-*     committers of YAKINDU - initial API and implementation
-*/
-#include <string>
-#include "gtest/gtest.h"
-#include "SimpleEvent.h"
-
-TEST(StatemachineTest, simpleEventTest) {
-	SimpleEvent* statechart = new SimpleEvent();
-	statechart->init();
-	statechart->enter();
-	EXPECT_TRUE(statechart->isActive(SimpleEvent::A)) << "Expected A to be active" ;
-	EXPECT_TRUE(5== 5);
-	statechart->raise_event1();
-	statechart->runCycle();
-	EXPECT_TRUE(statechart->isActive(SimpleEvent::B)) << "Expected B to be active" ;
-	delete statechart;
-}
+/**
+* Copyright (c) 2014 committers of YAKINDU and others.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+*     committers of YAKINDU - initial API and implementation
+*/
+#include <string>
+#include "gtest/gtest.h"
+#include "SimpleEvent.h"
+
+TEST(StatemachineTest, simpleEventTest) {
+	SimpleEvent* statechart = new SimpleEvent();
+	statechart->init();
+	statechart->enter();
+	EXPECT_TRUE(statechart->isActive(SimpleEvent::A)) << "Expected A to be active" ;
+	EXPECT_TRUE(5== 5);
+	statechart->raise_event1();
+	statechart->runCycle();
+	EXPECT_TRUE(statechart->isActive(SimpleEvent::B)) << "Expected B to be active" ;
+	statechart->runCycle();
+	EXPECT_TRUE(!statechart->isActive(SimpleEvent::B));
+	delete statechart;
+}

+ 39 - 39
test-plugins/org.yakindu.sct.generator.cpp.test/test-gen/org/yakindu/sct/generator/cpp/test/SimpleEventTest.java

@@ -1,39 +1,39 @@
-/**
- * Copyright (c) 2014 committers of YAKINDU and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     committers of YAKINDU - initial API and implementation
- */
-package org.yakindu.sct.generator.cpp.test;
-
-import java.util.Collection;
-
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.yakindu.sct.generator.c.gtest.GTest;
-import org.yakindu.sct.generator.c.gtest.GTestRunner;
-import org.yakindu.sct.generator.c.gtest.GTestHelper;
-
-@GTest(sourceFile = "gtests/SimpleEventTest/SimpleEventTest.cc", program = "gtests/SimpleEventTest/SimpleEvent", model = "testmodels/SCTUnit/SimpleEvent.sct")
-@RunWith(GTestRunner.class)
-public class SimpleEventTest {
-
-	protected final GTestHelper helper = new GTestHelper(this) {
-
-		@Override
-		protected void getSourceFiles(Collection<String> files) {
-			super.getSourceFiles(files);
-			files.add(getFileName(getTestProgram()) + ".cpp");
-		}
-	};
-
-	@Before
-	public void setUp() {
-		helper.generate();
-		helper.compile();
-	}
-}
+/**
+ * Copyright (c) 2014 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.generator.cpp.test;
+
+import java.util.Collection;
+
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.yakindu.sct.generator.c.gtest.GTest;
+import org.yakindu.sct.generator.c.gtest.GTestRunner;
+import org.yakindu.sct.generator.c.gtest.GTestHelper;
+
+@GTest(sourceFile = "gtests/SimpleEventTest/SimpleEventTest.cc", program = "gtests/SimpleEventTest/SimpleEvent", model = "testmodels/SCTUnit/SimpleEvent.sct")
+@RunWith(GTestRunner.class)
+public class SimpleEventTest {
+
+	protected final GTestHelper helper = new GTestHelper(this) {
+
+		@Override
+		protected void getSourceFiles(Collection<String> files) {
+			super.getSourceFiles(files);
+			files.add(getFileName(getTestProgram()) + ".cpp");
+		}
+	};
+
+	@Before
+	public void setUp() {
+		helper.generate();
+		helper.compile();
+	}
+}

+ 34 - 0
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/declarations/DeclarationsStatemachine.java

@@ -149,6 +149,16 @@ public class DeclarationsStatemachine implements IDeclarationsStatemachine {
 			this.varD = value;
 		}
 
+		private long varE;
+
+		public long getVarE() {
+			return varE;
+		}
+
+		public void setVarE(long value) {
+			this.varE = value;
+		}
+
 		public void clearEvents() {
 			evA = false;
 			evC = false;
@@ -293,6 +303,16 @@ public class DeclarationsStatemachine implements IDeclarationsStatemachine {
 			this.varD = value;
 		}
 
+		private long varE;
+
+		public long getVarE() {
+			return varE;
+		}
+
+		public void setVarE(long value) {
+			this.varE = value;
+		}
+
 		public void clearEvents() {
 			evA = false;
 			evC = false;
@@ -316,6 +336,7 @@ public class DeclarationsStatemachine implements IDeclarationsStatemachine {
 	private long varInB;
 	private double varInC;
 	private String varInD;
+	private long varInE;
 
 	private final State[] stateVector = new State[1];
 
@@ -343,6 +364,8 @@ public class DeclarationsStatemachine implements IDeclarationsStatemachine {
 
 		sCInterface.varD = "myString";
 
+		sCInterface.varE = 16;
+
 		sCIIfA.varA = false;
 
 		sCIIfA.varB = 1;
@@ -351,6 +374,8 @@ public class DeclarationsStatemachine implements IDeclarationsStatemachine {
 
 		sCIIfA.varD = "myString";
 
+		sCIIfA.varE = 16;
+
 		varInA = false;
 
 		varInB = 1;
@@ -358,6 +383,8 @@ public class DeclarationsStatemachine implements IDeclarationsStatemachine {
 		varInC = 1.0;
 
 		varInD = "myString";
+
+		varInE = 16;
 	}
 
 	public void enter() {
@@ -529,6 +556,13 @@ public class DeclarationsStatemachine implements IDeclarationsStatemachine {
 	public void setVarD(String value) {
 		sCInterface.setVarD(value);
 	}
+	public long getVarE() {
+		return sCInterface.getVarE();
+	}
+
+	public void setVarE(long value) {
+		sCInterface.setVarE(value);
+	}
 
 	/* Entry action for statechart 'Declarations'. */
 	private void entryAction() {

+ 4 - 0
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/declarations/IDeclarationsStatemachine.java

@@ -20,6 +20,8 @@ public interface IDeclarationsStatemachine extends IStatemachine {
 		public void setVarC(double value);
 		public String getVarD();
 		public void setVarD(String value);
+		public long getVarE();
+		public void setVarE(long value);
 
 	}
 
@@ -42,6 +44,8 @@ public interface IDeclarationsStatemachine extends IStatemachine {
 		public void setVarC(double value);
 		public String getVarD();
 		public void setVarD(String value);
+		public long getVarE();
+		public void setVarE(long value);
 
 	}
 

+ 20 - 1
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/simpleevent/SimpleEventStatemachine.java

@@ -19,7 +19,7 @@ public class SimpleEventStatemachine implements ISimpleEventStatemachine {
 	private SCInterfaceImpl sCInterface;
 
 	public enum State {
-		main_region_A, main_region_B, $NullState$
+		main_region_A, main_region_B, main_region__final_, $NullState$
 	};
 
 	private final State[] stateVector = new State[1];
@@ -60,6 +60,11 @@ public class SimpleEventStatemachine implements ISimpleEventStatemachine {
 				stateVector[0] = State.$NullState$;
 				break;
 
+			case main_region__final_ :
+				nextStateIndex = 0;
+				stateVector[0] = State.$NullState$;
+				break;
+
 			default :
 				break;
 		}
@@ -90,6 +95,8 @@ public class SimpleEventStatemachine implements ISimpleEventStatemachine {
 				return stateVector[0] == State.main_region_A;
 			case main_region_B :
 				return stateVector[0] == State.main_region_B;
+			case main_region__final_ :
+				return stateVector[0] == State.main_region__final_;
 			default :
 				return false;
 		}
@@ -124,6 +131,15 @@ public class SimpleEventStatemachine implements ISimpleEventStatemachine {
 
 	/* The reactions of state B. */
 	private void reactMain_region_B() {
+		nextStateIndex = 0;
+		stateVector[0] = State.$NullState$;
+
+		nextStateIndex = 0;
+		stateVector[0] = State.main_region__final_;
+	}
+
+	/* The reactions of state null. */
+	private void reactMain_region__final_0() {
 	}
 
 	public void runCycle() {
@@ -139,6 +155,9 @@ public class SimpleEventStatemachine implements ISimpleEventStatemachine {
 				case main_region_B :
 					reactMain_region_B();
 					break;
+				case main_region__final_ :
+					reactMain_region__final_0();
+					break;
 				default :
 					// $NullState$
 			}

+ 3 - 1
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/SimpleEventTest.java

@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2013 committers of YAKINDU and others.
+ * Copyright (c) 2014 committers of YAKINDU and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -46,5 +46,7 @@ public class SimpleEventTest {
 		statemachine.runCycle();
 		assertTrue("Expected B to be active",
 				statemachine.isStateActive(State.main_region_B));
+		statemachine.runCycle();
+		assertTrue(!statemachine.isStateActive(State.main_region_B));
 	}
 }

+ 2 - 0
test-plugins/org.yakindu.sct.simulation.core.sexec.test/test-gen/org/yakindu/sct/simulation/core/sexec/test/SimpleEventTest.java

@@ -41,5 +41,7 @@ public class SimpleEventTest extends AbstractExecutionFlowTest {
 		raiseEvent("Event1");
 		interpreter.runCycle();
 		assertTrue("Expected B to be active", isActive("B"));
+		interpreter.runCycle();
+		assertTrue(!isActive("B"));
 	}
 }

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 72 - 72
test-plugins/org.yakindu.sct.test.models/testmodels/SCTUnit/Declarations.sct


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 4 - 4
test-plugins/org.yakindu.sct.test.models/testmodels/SCTUnit/JavaKeywords.sct


+ 16 - 1
test-plugins/org.yakindu.sct.test.models/testmodels/SCTUnit/SimpleEvent.sct

@@ -8,7 +8,10 @@
       <vertices xsi:type="sgraph:State" xmi:id="_MFHNBJLHEeGc3OFlLS8sJA" name="A" incomingTransitions="_MFMFgJLHEeGc3OFlLS8sJA">
         <outgoingTransitions xmi:id="_QfOn4JLHEeGc3OFlLS8sJA" specification="Event1" target="_P5KGYJLHEeGc3OFlLS8sJA"/>
       </vertices>
-      <vertices xsi:type="sgraph:State" xmi:id="_P5KGYJLHEeGc3OFlLS8sJA" name="B" incomingTransitions="_QfOn4JLHEeGc3OFlLS8sJA"/>
+      <vertices xsi:type="sgraph:State" xmi:id="_P5KGYJLHEeGc3OFlLS8sJA" name="B" incomingTransitions="_QfOn4JLHEeGc3OFlLS8sJA">
+        <outgoingTransitions xmi:id="_iBHeENRjEeOsXeAQ9MK_iA" specification="always" target="_hCM-wNRjEeOsXeAQ9MK_iA"/>
+      </vertices>
+      <vertices xsi:type="sgraph:FinalState" xmi:id="_hCM-wNRjEeOsXeAQ9MK_iA" incomingTransitions="_iBHeENRjEeOsXeAQ9MK_iA"/>
     </regions>
   </sgraph:Statechart>
   <notation:Diagram xmi:id="_MEStoJLHEeGc3OFlLS8sJA" type="org.yakindu.sct.ui.editor.editor.StatechartDiagramEditor" element="_MEOcMJLHEeGc3OFlLS8sJA" measurementUnit="Pixel">
@@ -62,6 +65,9 @@
           <styles xsi:type="notation:BooleanValueStyle" xmi:id="_P5dBUZLHEeGc3OFlLS8sJA"/>
           <layoutConstraint xsi:type="notation:Bounds" xmi:id="_P5alE5LHEeGc3OFlLS8sJA" x="234" y="74"/>
         </children>
+        <children xsi:type="notation:Shape" xmi:id="_hCtVENRjEeOsXeAQ9MK_iA" type="FinalState" element="_hCM-wNRjEeOsXeAQ9MK_iA" fontName="Verdana" lineColor="4210752">
+          <layoutConstraint xsi:type="notation:Bounds" xmi:id="_hCtVEdRjEeOsXeAQ9MK_iA" x="244" y="197"/>
+        </children>
         <layoutConstraint xsi:type="notation:Bounds" xmi:id="_MFC7kZLHEeGc3OFlLS8sJA"/>
       </children>
       <styles xsi:type="notation:ShapeStyle" xmi:id="_MEgJAZLHEeGc3OFlLS8sJA" fontName="Verdana" fillColor="15790320" lineColor="12632256"/>
@@ -97,5 +103,14 @@
       <bendpoints xsi:type="notation:RelativeBendpoints" xmi:id="_QfVVkpLHEeGc3OFlLS8sJA" points="[33, 2, -146, -11]$[174, -12, -5, -25]"/>
       <sourceAnchor xsi:type="notation:IdentityAnchor" xmi:id="_QfjYAJLHEeGc3OFlLS8sJA" id="(0.075,0.30357142857142855)"/>
     </edges>
+    <edges xmi:id="_iBNksNRjEeOsXeAQ9MK_iA" type="Transition" element="_iBHeENRjEeOsXeAQ9MK_iA" source="_P5alEJLHEeGc3OFlLS8sJA" target="_hCtVENRjEeOsXeAQ9MK_iA">
+      <children xsi:type="notation:DecorationNode" xmi:id="_iBWHkNRjEeOsXeAQ9MK_iA" type="TransitionExpression">
+        <styles xsi:type="notation:ShapeStyle" xmi:id="_iBWHkdRjEeOsXeAQ9MK_iA"/>
+        <layoutConstraint xsi:type="notation:Location" xmi:id="_iBWuoNRjEeOsXeAQ9MK_iA" x="1" y="-30"/>
+      </children>
+      <styles xsi:type="notation:ConnectorStyle" xmi:id="_iBNksdRjEeOsXeAQ9MK_iA" lineColor="4210752"/>
+      <styles xsi:type="notation:FontStyle" xmi:id="_iBOLwNRjEeOsXeAQ9MK_iA" fontName="Verdana"/>
+      <bendpoints xsi:type="notation:RelativeBendpoints" xmi:id="_iBNkstRjEeOsXeAQ9MK_iA" points="[3, 24, -18, -110]$[16, 129, -5, -5]"/>
+    </edges>
   </notation:Diagram>
 </xmi:XMI>

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

@@ -1,7 +1,6 @@
 testgroup Declarations for statechart Declarations {
 	
 	test declarationsTest {
-		
 		enter
 	}
 }

+ 3 - 0
test-plugins/org.yakindu.sct.test.models/tests/SimpleEvent.sctunit

@@ -8,6 +8,9 @@ testgroup SimpleEvent for statechart SimpleEvent {
 		raise Event1
 		cycle
 		assert active (SimpleEvent.main_region.B) "Expected B to be active"
+		
+		cycle
+		assert !active (SimpleEvent.main_region.B)	
 		      
 	}        
 }