Browse Source

add tests: generator.java.test.StringExpressions; sexec.interpreter.test.CKeywords.java, sexec.interpreter.test.StringExpressions.java; sct.test.models.Alltests.sctunit, sct.test.models.StringExpressions.sctunit

Andreas Mülder 13 years ago
parent
commit
f49407e860

+ 50 - 0
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/sct/generator/java/test/StringExpressions.java

@@ -0,0 +1,50 @@
+/**
+ * Copyright (c) 2012 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.java.test;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.yakindu.scr.stringexpressions.StringExpressionsStatemachine;
+import org.yakindu.scr.stringexpressions.StringExpressionsStatemachine.State;
+/**
+ *  Unit TestCase for StringExpressions
+ */
+@SuppressWarnings("all")
+public class StringExpressions {
+
+	private StringExpressionsStatemachine statemachine;
+
+	@Before
+	public void setUp() {
+		statemachine = new StringExpressionsStatemachine();
+		statemachine.init();
+		statemachine.enter();
+	}
+
+	@After
+	public void tearDown() {
+		statemachine = null;
+	}
+
+	@Test
+	public void testStringExpressionsTest() {
+		assertTrue(statemachine.isStateActive(State.Main_region_StateA));
+		assertTrue(statemachine.getMyString().equals("hello"));
+		assertTrue(statemachine.getMyString2().equals("world"));
+		statemachine.raiseE1();
+		statemachine.runCycle();
+		assertTrue(statemachine.isStateActive(State.Main_region_StateB));
+		assertTrue(statemachine.getEquals() == false);
+		assertTrue(statemachine.getNotEqual() == true);
+	}
+}

+ 50 - 0
test-plugins/org.yakindu.sct.model.sexec.interpreter.test/src-gen/org/yakindu/sct/model/sexec/interpreter/test/CKeywordsTest.java

@@ -0,0 +1,50 @@
+/**
+ * Copyright (c) 2012 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.model.sexec.interpreter.test;
+import org.eclipse.xtext.junit4.InjectWith;
+import org.eclipse.xtext.junit4.XtextRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.yakindu.sct.model.sexec.interpreter.test.util.AbstractExecutionFlowTest;
+import org.yakindu.sct.model.sexec.interpreter.test.util.SExecInjectionProvider;
+import com.google.inject.Inject;
+import org.junit.Before;
+import org.yakindu.sct.model.sexec.interpreter.IExecutionFlowInterpreter;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import util.TestModels;
+import static junit.framework.Assert.*;
+/**
+ *  Unit TestCase for CKeywords
+ */
+@SuppressWarnings("all")
+@RunWith(XtextRunner.class)
+@InjectWith(SExecInjectionProvider.class)
+public class CKeywordsTest extends AbstractExecutionFlowTest {
+
+	@Inject
+	private TestModels models;
+
+	@Before
+	public void setup() throws Exception {
+		ExecutionFlow flow = models
+				.loadExecutionFlowFromResource("CKeywords.sct");
+		initInterpreter(flow);
+	}
+	@Test
+	public void CKeywordsTest() throws Exception {
+		assertTrue(isActive("char"));
+		raiseEvent("auto");
+		interpreter.runCycle();
+		assertTrue(isActive("const"));
+		assertTrue(isActive("case"));
+		assertTrue(isActive("asm"));
+	}
+}

+ 52 - 0
test-plugins/org.yakindu.sct.model.sexec.interpreter.test/src-gen/org/yakindu/sct/model/sexec/interpreter/test/StringExpressionsTest.java

@@ -0,0 +1,52 @@
+/**
+ * Copyright (c) 2012 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.model.sexec.interpreter.test;
+import org.eclipse.xtext.junit4.InjectWith;
+import org.eclipse.xtext.junit4.XtextRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.yakindu.sct.model.sexec.interpreter.test.util.AbstractExecutionFlowTest;
+import org.yakindu.sct.model.sexec.interpreter.test.util.SExecInjectionProvider;
+import com.google.inject.Inject;
+import org.junit.Before;
+import org.yakindu.sct.model.sexec.interpreter.IExecutionFlowInterpreter;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import util.TestModels;
+import static junit.framework.Assert.*;
+/**
+ *  Unit TestCase for StringExpressions
+ */
+@SuppressWarnings("all")
+@RunWith(XtextRunner.class)
+@InjectWith(SExecInjectionProvider.class)
+public class StringExpressionsTest extends AbstractExecutionFlowTest {
+
+	@Inject
+	private TestModels models;
+
+	@Before
+	public void setup() throws Exception {
+		ExecutionFlow flow = models
+				.loadExecutionFlowFromResource("StringExpressions.sct");
+		initInterpreter(flow);
+	}
+	@Test
+	public void StringExpressionsTest() throws Exception {
+		assertTrue(isActive("StateA"));
+		assertTrue(getString("myString").equals("hello"));
+		assertTrue(getString("myString2").equals("world"));
+		raiseEvent("e1");
+		interpreter.runCycle();
+		assertTrue(isActive("StateB"));
+		assertTrue(getBoolean("equals") == false);
+		assertTrue(getBoolean("notEqual") == true);
+	}
+}

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

@@ -4,6 +4,6 @@ testsuite AllTests {
 	//FeatureCalls,
 	Guard , IntegerExpressions ,
 	PriorityValues , RaiseEvent , SameNameDifferentRegion , ShallowHistory ,
-	SimpleHietachy , StateIsActive , StatechartLocalReactions , SyncFork ,
+	SimpleHietachy , StateIsActive , StatechartLocalReactions , StringExpressions, SyncFork ,
 	SyncJoin , ValuedEvent , simpleEvent 
 }

+ 12 - 0
test-plugins/org.yakindu.sct.test.models/tests/StringExpressions.sctunit

@@ -0,0 +1,12 @@
+testgroup StringExpressions for statechart StringExpressions	{
+	test StringExpressionsTest {
+		assert active (StringExpressions.main_region.StateA)
+		assert myString == "hello"
+		assert myString2 == "world"
+		raise e1
+		cycle
+		assert active (StringExpressions.main_region.StateB)
+		assert equals == false
+		assert notEqual == true
+	}
+}