Przeglądaj źródła

Added test cases for: Transition into substate does not recognize parents history context (Fixes issue 33)

terfloth@itemis.de 10 lat temu
rodzic
commit
fd1decc689

+ 9 - 1
test-plugins/org.yakindu.sct.simulation.core.sexec.test/model/test.sgen

@@ -257,7 +257,7 @@ GeneratorModel for sctunit::interpreter {
 			targetFolder = "test-gen"			
 		}			
 	}
-
+	
 	test OutEventLifeCycle{
 		
 		feature Outlet{ 
@@ -307,6 +307,14 @@ GeneratorModel for sctunit::interpreter {
 		}			
 	}
 	
+	test ShallowHistoryWithDeepEntry {
+		
+		feature Outlet{ 
+			targetProject = "org.yakindu.sct.simulation.core.sexec.test" 
+			targetFolder = "test-gen"			
+		}			
+	}
+	
 	test SimpleEvent{
 		
 		feature Outlet{ 

+ 5 - 4
test-plugins/org.yakindu.sct.simulation.core.sexec.test/test-gen/org/yakindu/sct/simulation/core/sexec/test/AllTestsTest.java

@@ -31,10 +31,11 @@ import org.junit.runners.Suite.SuiteClasses;
 		NamedInterfaceAccessTest.class, OutEventLifeCycleTest.class,
 		ParenthesisTest.class, PriorityValuesTest.class, RaiseEventTest.class,
 		SameNameDifferentRegionTest.class, ShallowHistoryTest.class,
-		SimpleEventTest.class, StatechartLocalReactionsTest.class,
-		SimpleHierachyTest.class, StateIsActiveTest.class,
-		StaticChoiceTest.class, STextKeywordsInStatesAndRegionsTest.class,
-		StringExpressionsTest.class, SyncForkTest.class, SyncJoinTest.class,
+		ShallowHistoryWithDeepEntryTest.class, SimpleEventTest.class,
+		StatechartLocalReactionsTest.class, SimpleHierachyTest.class,
+		StateIsActiveTest.class, StaticChoiceTest.class,
+		STextKeywordsInStatesAndRegionsTest.class, StringExpressionsTest.class,
+		SyncForkTest.class, SyncJoinTest.class,
 		TransitionWithoutConditionTest.class, ValuedEventsTest.class})
 public class AllTestsTest {
 }

+ 0 - 4
test-plugins/org.yakindu.sct.simulation.core.sexec.test/test-gen/org/yakindu/sct/simulation/core/sexec/test/CastExpressionsTest.java

@@ -12,16 +12,13 @@ package org.yakindu.sct.simulation.core.sexec.test;
 import org.eclipse.xtext.junit4.InjectWith;
 import org.eclipse.xtext.junit4.XtextRunner;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.yakindu.sct.model.sexec.ExecutionFlow;
 import org.yakindu.sct.model.sexec.interpreter.test.util.AbstractExecutionFlowTest;
 import org.yakindu.sct.model.sexec.interpreter.test.util.SExecInjectionProvider;
 import org.yakindu.sct.test.models.SCTUnitTestModels;
-
 import com.google.inject.Inject;
-
 import static org.junit.Assert.assertTrue;
 /**
  *  Unit TestCase for CastExpressions
@@ -37,7 +34,6 @@ public class CastExpressionsTest extends AbstractExecutionFlowTest {
 		initInterpreter(flow);
 	}
 	@Test
-	@Ignore
 	public void CastExpressionTest() throws Exception {
 		interpreter.enter();
 		assertTrue(getReal("realValue") == 5);

+ 9 - 9
test-plugins/org.yakindu.sct.simulation.core.sexec.test/test-gen/org/yakindu/sct/simulation/core/sexec/test/HistoryWithoutInitialStepTest.java

@@ -37,10 +37,10 @@ public class HistoryWithoutInitialStepTest extends AbstractExecutionFlowTest {
 	public void enterThroughInitialEntry() throws Exception {
 		interpreter.enter();
 		assertTrue(isActive("A"));
-		raiseEvent("e1");
+		raiseEvent("toB");
 		interpreter.runCycle();
 		assertTrue(isActive("C"));
-		raiseEvent("e2");
+		raiseEvent("next");
 		interpreter.runCycle();
 		assertTrue(isActive("D"));
 	}
@@ -48,13 +48,13 @@ public class HistoryWithoutInitialStepTest extends AbstractExecutionFlowTest {
 	public void enterCThroughHistory() throws Exception {
 		interpreter.enter();
 		assertTrue(isActive("A"));
-		raiseEvent("e1");
+		raiseEvent("toB");
 		interpreter.runCycle();
 		assertTrue(isActive("C"));
-		raiseEvent("e1");
+		raiseEvent("toA");
 		interpreter.runCycle();
 		assertTrue(isActive("A"));
-		raiseEvent("e2");
+		raiseEvent("toHistory");
 		interpreter.runCycle();
 		assertTrue(isActive("C"));
 	}
@@ -62,15 +62,15 @@ public class HistoryWithoutInitialStepTest extends AbstractExecutionFlowTest {
 	public void enterDThroughHistory() throws Exception {
 		interpreter.enter();
 		assertTrue(isActive("A"));
-		raiseEvent("e1");
+		raiseEvent("toB");
 		interpreter.runCycle();
-		raiseEvent("e2");
+		raiseEvent("next");
 		interpreter.runCycle();
 		assertTrue(isActive("D"));
-		raiseEvent("e1");
+		raiseEvent("toA");
 		interpreter.runCycle();
 		assertTrue(isActive("A"));
-		raiseEvent("e2");
+		raiseEvent("toHistory");
 		interpreter.runCycle();
 		assertTrue(isActive("D"));
 	}

+ 85 - 0
test-plugins/org.yakindu.sct.simulation.core.sexec.test/test-gen/org/yakindu/sct/simulation/core/sexec/test/ShallowHistoryWithDeepEntryTest.java

@@ -0,0 +1,85 @@
+/**
+ * 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.simulation.core.sexec.test;
+import org.eclipse.xtext.junit4.InjectWith;
+import org.eclipse.xtext.junit4.XtextRunner;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sexec.interpreter.test.util.AbstractExecutionFlowTest;
+import org.yakindu.sct.model.sexec.interpreter.test.util.SExecInjectionProvider;
+import org.yakindu.sct.test.models.SCTUnitTestModels;
+import com.google.inject.Inject;
+import static org.junit.Assert.assertTrue;
+/**
+ *  Unit TestCase for ShallowHistoryWithDeepEntry
+ */
+@SuppressWarnings("all")
+@RunWith(XtextRunner.class)
+@InjectWith(SExecInjectionProvider.class)
+public class ShallowHistoryWithDeepEntryTest extends AbstractExecutionFlowTest {
+	@Before
+	public void setup() throws Exception {
+		ExecutionFlow flow = models
+				.loadExecutionFlowFromResource("ShallowHistoryWithDeepEntry.sct");
+		initInterpreter(flow);
+	}
+	@Test
+	public void noDeepEntryWithinHistory() throws Exception {
+		interpreter.enter();
+		assertTrue(isActive("Y"));
+		raiseEvent("toZ");
+		interpreter.runCycle();
+		assertTrue(isActive("A"));
+		raiseEvent("toY");
+		interpreter.runCycle();
+		assertTrue(isActive("Y"));
+		raiseEvent("toZ");
+		interpreter.runCycle();
+		assertTrue(isActive("A"));
+	}
+	@Test
+	public void deepEntryWithinHistory() throws Exception {
+		interpreter.enter();
+		assertTrue(isActive("Y"));
+		raiseEvent("toZ");
+		interpreter.runCycle();
+		assertTrue(isActive("A"));
+		raiseEvent("toC");
+		interpreter.runCycle();
+		assertTrue(isActive("C"));
+		assertTrue(isActive("B"));
+		raiseEvent("toY");
+		interpreter.runCycle();
+		assertTrue(isActive("Y"));
+		raiseEvent("toZ");
+		interpreter.runCycle();
+		assertTrue(isActive("C"));
+		assertTrue(isActive("B"));
+	}
+	@Test
+	public void directDeepEntryIntoHistory() throws Exception {
+		interpreter.enter();
+		assertTrue(isActive("Y"));
+		raiseEvent("toC");
+		interpreter.runCycle();
+		assertTrue(isActive("C"));
+		assertTrue(isActive("B"));
+		raiseEvent("toY");
+		interpreter.runCycle();
+		assertTrue(isActive("Y"));
+		raiseEvent("toZ");
+		interpreter.runCycle();
+		assertTrue(isActive("C"));
+		assertTrue(isActive("B"));
+	}
+}