فهرست منبع

Merge pull request #506 from Yakindu/issue_438_escape_declarations

Issue 438 escape declarations
Markus Mühlbrandt 9 سال پیش
والد
کامیت
a5829a23de

+ 19 - 0
test-plugins/org.yakindu.sct.generator.c.test/gtests/StatemachineKeywords/StatechartKeywords.sgen

@@ -0,0 +1,19 @@
+GeneratorModel for yakindu::c {
+	statechart StatechartKeywords {
+		feature Outlet {
+			targetProject = "gtests"
+			targetFolder = "StatemachineKeywords"
+		}
+		feature FunctionInlining {
+			inlineReactions = false
+			inlineEntryActions = false
+			inlineEnterSequences = false 
+			inlineExitActions = false
+			inlineExitSequences = false
+			inlineChoices = false
+			inlineEntries = false
+			inlineEnterRegion = false
+			inlineExitRegion = false
+		}
+	}
+}

+ 31 - 0
test-plugins/org.yakindu.sct.generator.c.test/gtests/StatemachineKeywords/StatemachineKeywords.cc

@@ -0,0 +1,31 @@
+/**
+* Copyright (c) 2016 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 "StatechartKeywords.h"
+#include "StatechartKeywordsRequired.h"
+
+StatechartKeywords handle;
+
+TEST(StatemachineTest, statemachineKeywords) {
+	statechartKeywords_init(&handle);
+	statechartKeywords_enter(&handle);
+	EXPECT_TRUE(statechartKeywords_isStateActive(&handle, StatechartKeywords_main_region_Timer));
+}
+
+void statechartKeywords_setTimer(StatechartKeywords* handle, const sc_eventid evid, const sc_integer time_ms, const sc_boolean periodic){
+	// Mockup
+	statechartKeywords_raiseTimeEvent(handle, evid);
+}
+
+void statechartKeywords_unsetTimer(StatechartKeywords* handle, const sc_eventid evid){
+	// Mockup
+}		

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 729 - 708
test-plugins/org.yakindu.sct.generator.c.test/model/test.sgen


+ 5 - 5
test-plugins/org.yakindu.sct.generator.c.test/test-gen/org/yakindu/sct/generator/c/test/AllTests.java

@@ -15,11 +15,11 @@ import org.junit.runners.Suite.SuiteClasses;
 
 @RunWith(Suite.class)
 @SuiteClasses({AlwaysOncycle.class, AssignmentAsExpression.class, BitExpressions.class, BooleanExpressions.class,
-		CastExpressions.class, Choice.class, CKeywords.class, ConditionalExpression.class, ConstantsTests.class,
-		Declarations.class, DeepEntry.class, DeepHistory.class, DynamicChoice.class, EmptyTransition.class,
-		EnterState.class, EntryChoice.class, EntryExitSelfTransition.class, EntryReactionAction.class,
-		ExitOnSelfTransition.class, ExitState.class, FeatureCalls.class, FinalState.class, Guard.class,
-		GuardedEntry.class, GuardedExit.class, HistoryWithExitPoint.class, HistoryWithoutInitialStep.class,
+		CastExpressions.class, Choice.class, CKeywords.class, StatemachineKeywords.class, ConditionalExpression.class,
+		ConstantsTests.class, Declarations.class, DeepEntry.class, DeepHistory.class, DynamicChoice.class,
+		EmptyTransition.class, EnterState.class, EntryChoice.class, EntryExitSelfTransition.class,
+		EntryReactionAction.class, ExitOnSelfTransition.class, ExitState.class, FeatureCalls.class, FinalState.class,
+		Guard.class, GuardedEntry.class, GuardedExit.class, HistoryWithExitPoint.class, HistoryWithoutInitialStep.class,
 		InEventLifeCycle.class, IntegerExpressions.class, InternalEventLifeCycle.class, LocalReactions.class,
 		LogicalAndTests.class, LogicalOrTests.class, NamedInterfaceAccess.class, OutEventLifeCycle.class,
 		Parenthesis.class, PriorityValues.class, RaiseEvent.class, ReadOnlyVariable.class,

+ 39 - 0
test-plugins/org.yakindu.sct.generator.c.test/test-gen/org/yakindu/sct/generator/c/test/StatemachineKeywords.java

@@ -0,0 +1,39 @@
+/**
+* Copyright (c) 2016 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.c.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/StatemachineKeywords/StatemachineKeywords.cc", program = "gtests/StatemachineKeywords/StatechartKeywords", model = "testmodels/SCTUnit/StatechartKeywords.sct")
+@RunWith(GTestRunner.class)
+public class StatemachineKeywords {
+
+	protected final GTestHelper helper = new GTestHelper(this) {
+
+		@Override
+		protected void getSourceFiles(Collection<String> files) {
+			super.getSourceFiles(files);
+			files.add(getFileName(getTestProgram()) + ".c");
+		}
+	};
+
+	@Before
+	public void setUp() {
+		helper.generate();
+		helper.compile();
+	}
+}

+ 9 - 1
test-plugins/org.yakindu.sct.generator.java.test/model/test.sgen

@@ -485,5 +485,13 @@ GeneratorModel for sctunit::java {
 			targetProject = "org.yakindu.sct.generator.java.test" 
 			targetFolder = "test-gen"			
 		}			
-	}		
+	}
+	
+	test StatemachineKeywords {
+
+		feature Outlet {
+			targetProject = "org.yakindu.sct.generator.java.test"
+			targetFolder = "test-gen"
+		}
+	}
 }

+ 10 - 9
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/AllTestsTest.java

@@ -16,15 +16,16 @@ import org.junit.runners.Suite.SuiteClasses;
 @RunWith(Suite.class)
 @SuiteClasses({AlwaysOncycleTest.class, AssignmentAsExpressionTest.class, BitExpressionsTest.class,
 		BooleanExpressionsTest.class, CastExpressionsTest.class, ChoiceTest.class, CKeywordsTest.class,
-		ConditionalExpressionTest.class, ConstantsTestsTest.class, DeclarationsTest.class, DeepEntryTest.class,
-		DeepHistoryTest.class, DynamicChoiceTest.class, EmptyTransitionTest.class, EnterStateTest.class,
-		EntryChoiceTest.class, EntryExitSelfTransitionTest.class, EntryReactionActionTest.class,
-		ExitOnSelfTransitionTest.class, ExitStateTest.class, FeatureCallsTest.class, FinalStateTest.class,
-		GuardTest.class, GuardedEntryTest.class, GuardedExitTest.class, HistoryWithExitPointTest.class,
-		HistoryWithoutInitialStepTest.class, InEventLifeCycleTest.class, IntegerExpressionsTest.class,
-		InternalEventLifeCycleTest.class, LocalReactionsTest.class, LogicalAndTestsTest.class, LogicalOrTestsTest.class,
-		NamedInterfaceAccessTest.class, OutEventLifeCycleTest.class, ParenthesisTest.class, PriorityValuesTest.class,
-		RaiseEventTest.class, ReadOnlyVariableTest.class, SameNameDifferentRegionTest.class, ShallowHistoryTest.class,
+		StatemachineKeywordsTest.class, ConditionalExpressionTest.class, ConstantsTestsTest.class,
+		DeclarationsTest.class, DeepEntryTest.class, DeepHistoryTest.class, DynamicChoiceTest.class,
+		EmptyTransitionTest.class, EnterStateTest.class, EntryChoiceTest.class, EntryExitSelfTransitionTest.class,
+		EntryReactionActionTest.class, ExitOnSelfTransitionTest.class, ExitStateTest.class, FeatureCallsTest.class,
+		FinalStateTest.class, GuardTest.class, GuardedEntryTest.class, GuardedExitTest.class,
+		HistoryWithExitPointTest.class, HistoryWithoutInitialStepTest.class, InEventLifeCycleTest.class,
+		IntegerExpressionsTest.class, InternalEventLifeCycleTest.class, LocalReactionsTest.class,
+		LogicalAndTestsTest.class, LogicalOrTestsTest.class, NamedInterfaceAccessTest.class,
+		OutEventLifeCycleTest.class, ParenthesisTest.class, PriorityValuesTest.class, RaiseEventTest.class,
+		ReadOnlyVariableTest.class, SameNameDifferentRegionTest.class, ShallowHistoryTest.class,
 		ShallowHistoryWithDeepEntryTest.class, SimpleEventTest.class, SimpleHierachyTest.class,
 		StatechartActiveTest.class, StatechartLocalReactionsTest.class, StateIsActiveTest.class, StaticChoiceTest.class,
 		STextKeywordsInStatesAndRegionsTest.class, StringExpressionsTest.class, SyncForkTest.class, SyncJoinTest.class,

+ 46 - 0
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/StatemachineKeywordsTest.java

@@ -0,0 +1,46 @@
+/**
+* Copyright (c) 2016 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.statechartkeywords.StatechartKeywordsStatemachine;
+import org.yakindu.scr.statechartkeywords.StatechartKeywordsStatemachine.State;
+import org.yakindu.scr.TimerService;
+/**
+ *  Unit TestCase for StatechartKeywords
+ */
+@SuppressWarnings("all")
+public class StatemachineKeywordsTest {
+
+	private StatechartKeywordsStatemachine statemachine;
+
+	@Before
+	public void setUp() {
+		statemachine = new StatechartKeywordsStatemachine();
+		statemachine.setTimer(new TimerService());
+		statemachine.init();
+	}
+
+	@After
+	public void tearDown() {
+		statemachine = null;
+	}
+
+	@Test
+	public void teststatemachineKeywords() {
+		statemachine.enter();
+		assertTrue(statemachine.isStateActive(State.main_region_Timer));
+	}
+}

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

@@ -6,6 +6,7 @@ testsuite AllTests {
 	CastExpressions,
 	Choice, 
 	CKeywords,
+	StatemachineKeywords,
 	ConditionalExpression,
 	ConstantsTests,
 	Declarations, 

+ 9 - 0
test-plugins/org.yakindu.sct.test.models/tests/StatemachineKeywords.sctunit

@@ -0,0 +1,9 @@
+
+testgroup StatemachineKeywords for statechart StatechartKeywords {
+	test statemachineKeywords { 
+		enter
+		assert active(StatechartKeywords.main_region.Timer) 
+		 
+	} 
+}
+