فهرست منبع

added test for logical and expression (Bug YAKHMI-912)

terfloth@itemis.de 12 سال پیش
والد
کامیت
0a1f937fdf

+ 8 - 0
test-plugins/org.yakindu.sct.generator.c.test/model/test.sgen

@@ -159,7 +159,15 @@ GeneratorModel for sctunit::c {
 			targetFolder = "test-gen"			
 		}			
 	}
+		 
+	test LogicalAndTests{
 		
+		feature Outlet{ 
+			targetProject = "org.yakindu.sct.generator.c.test" 
+			targetFolder = "test-gen"			
+		}			
+	}
+	
 	test NamedInterfaceAccess{
 		
 		feature Outlet{ 

+ 8 - 0
test-plugins/org.yakindu.sct.generator.cpp.test/model/test.sgen

@@ -152,6 +152,14 @@ GeneratorModel for sctunit::cpp {
 		}			
 	}
 		
+	test LogicalAndTests{
+		
+		feature Outlet{ 
+			targetProject = "org.yakindu.sct.generator.cpp.test" 
+			targetFolder = "test-gen"			
+		}			
+	}
+		
 	test NamedInterfaceAccess{
 		
 		feature Outlet{ 

+ 13 - 0
test-plugins/org.yakindu.sct.generator.java.test/model/model.sgen

@@ -1,4 +1,5 @@
 GeneratorModel for yakindu::java {
+	
 	statechart AlwaysOncycle {
 		feature Outlet {
 			targetProject = "org.yakindu.sct.generator.java.test"
@@ -470,5 +471,17 @@ GeneratorModel for yakindu::java {
 		}
 	}
 	
+	statechart LogicalAnd {
+			feature Outlet {
+			targetProject = "org.yakindu.sct.generator.java.test"
+			targetFolder = "src-gen"
+		} 
+
+		feature GeneralFeatures {
+			TimerService = true
+			RuntimeService = true
+		}
+		
+	}
 
 }

+ 8 - 0
test-plugins/org.yakindu.sct.generator.java.test/model/test.sgen

@@ -160,6 +160,14 @@ GeneratorModel for sctunit::java {
 		}			
 	}
 		
+	test LogicalAndTests{
+		
+		feature Outlet{ 
+			targetProject = "org.yakindu.sct.generator.java.test" 
+			targetFolder = "test-gen"			
+		}			
+	}
+		
 	test NamedInterfaceAccess{
 		
 		feature Outlet{ 

+ 2 - 2
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/exitstate/ExitStateStatemachine.java

@@ -125,7 +125,7 @@ public class ExitStateStatemachine implements IExitStateStatemachine {
 	}
 
 	private boolean checkR_A_r_BTr0() {
-		return sCInterface.e;
+		return sCInterface.g;
 	}
 
 	private boolean checkR_A_r_BTr1() {
@@ -133,7 +133,7 @@ public class ExitStateStatemachine implements IExitStateStatemachine {
 	}
 
 	private boolean checkR_A_r_BTr2() {
-		return sCInterface.g;
+		return sCInterface.e;
 	}
 
 	private void effectR_ATr0() {

+ 16 - 0
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/logicaland/ILogicalAndStatemachine.java

@@ -0,0 +1,16 @@
+package org.yakindu.scr.logicaland;
+import org.yakindu.scr.IStatemachine;
+
+public interface ILogicalAndStatemachine extends IStatemachine {
+
+	public interface SCInterface {
+		public int getX();
+		public void setX(int value);
+		public boolean getB();
+		public void setB(boolean value);
+
+	}
+
+	public SCInterface getSCInterface();
+
+}

+ 151 - 0
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/logicaland/LogicalAndStatemachine.java

@@ -0,0 +1,151 @@
+package org.yakindu.scr.logicaland;
+
+public class LogicalAndStatemachine implements ILogicalAndStatemachine {
+
+	private final class SCInterfaceImpl implements SCInterface {
+
+		private int x;
+
+		public int getX() {
+			return x;
+		}
+
+		public void setX(int value) {
+			this.x = value;
+		}
+
+		private boolean b;
+
+		public boolean getB() {
+			return b;
+		}
+
+		public void setB(boolean value) {
+			this.b = value;
+		}
+
+	}
+
+	private SCInterfaceImpl sCInterface;
+
+	public enum State {
+		main_region_A, $NullState$
+	};
+
+	private final State[] stateVector = new State[1];
+
+	private int nextStateIndex;
+
+	public LogicalAndStatemachine() {
+
+		sCInterface = new SCInterfaceImpl();
+	}
+
+	public void init() {
+		for (int i = 0; i < 1; i++) {
+			stateVector[i] = State.$NullState$;
+		}
+
+		clearEvents();
+		clearOutEvents();
+
+		sCInterface.x = 1;
+
+		sCInterface.b = false;
+	}
+
+	public void enter() {
+		entryAction();
+
+		nextStateIndex = 0;
+		stateVector[0] = State.main_region_A;
+	}
+
+	public void exit() {
+		switch (stateVector[0]) {
+			case main_region_A :
+				nextStateIndex = 0;
+				stateVector[0] = State.$NullState$;
+				break;
+
+			default :
+				break;
+		}
+
+		exitAction();
+	}
+
+	protected void clearEvents() {
+
+	}
+
+	protected void clearOutEvents() {
+	}
+
+	public boolean isStateActive(State state) {
+		switch (state) {
+			case main_region_A :
+				return stateVector[0] == State.main_region_A;
+			default :
+				return false;
+		}
+	}
+
+	public SCInterface getSCInterface() {
+		return sCInterface;
+	}
+
+	public int getX() {
+		return sCInterface.getX();
+	}
+
+	public void setX(int value) {
+		sCInterface.setX(value);
+	}
+	public boolean getB() {
+		return sCInterface.getB();
+	}
+
+	public void setB(boolean value) {
+		sCInterface.setB(value);
+	}
+
+	/* Entry action for statechart 'LogicalAnd'. */
+	private void entryAction() {
+	}
+
+	/* Exit action for state 'LogicalAnd'. */
+	private void exitAction() {
+	}
+
+	/* The reactions of state A. */
+	private void reactMain_region_A() {
+		if (sCInterface.x == 1) {
+			nextStateIndex = 0;
+			stateVector[0] = State.$NullState$;
+
+			sCInterface.b = ((sCInterface.x += 1) == 2 && (sCInterface.x *= 2) == 4);
+
+			nextStateIndex = 0;
+			stateVector[0] = State.main_region_A;
+		}
+	}
+
+	public void runCycle() {
+
+		clearOutEvents();
+
+		for (nextStateIndex = 0; nextStateIndex < stateVector.length; nextStateIndex++) {
+
+			switch (stateVector[nextStateIndex]) {
+				case main_region_A :
+					reactMain_region_A();
+					break;
+				default :
+					// $NullState$
+			}
+		}
+
+		clearEvents();
+	}
+}