Browse Source

made test executable

terfloth@itemis.de 13 years ago
parent
commit
d286d05036

+ 10 - 2
test-plugins/org.yakindu.sct.model.sexec.interpreter.test/src/org/yakindu/sct/model/sexec/interpreter/test/AbstractSTextTest.java

@@ -17,6 +17,7 @@ import org.yakindu.sct.model.sexec.interpreter.stext.StextStatementInterpreter;
 import org.yakindu.sct.model.sgraph.Scope;
 import org.yakindu.sct.model.sgraph.Statement;
 import org.yakindu.sct.model.stext.STextStandaloneSetup;
+import org.yakindu.sct.model.stext.stext.Expression;
 import org.yakindu.sct.simulation.core.runtime.IExecutionContext;
 import org.yakindu.sct.simulation.core.runtime.impl.ExecutionContextImpl;
 import org.yakindu.sct.simulation.core.runtime.impl.ExecutionEvent;
@@ -116,14 +117,14 @@ public class AbstractSTextTest {
 
 	protected Scope createContextScope(String contextScope) {
 		ParserRule parserRule = XtextFactory.eINSTANCE.createParserRule();
-		parserRule.setName("SimpleScope");
+		parserRule.setName("InternalScope");
 		IParseResult result = parser.parse(parserRule, new StringReader(
 				contextScope));
 		return (Scope) result.getRootASTElement();
 	}
 
 	protected Object executeWithDefaultScope(String expression) {
-		Scope defaultScope = createContextScope("event abc : integer operation foo() var myInt : integer var myBool : boolean var myFloat : real");
+		Scope defaultScope = createContextScope("internal: event abc : integer operation foo() var myInt : integer var myBool : boolean var myFloat : real");
 		Statement statement = (Statement) parseExpression(expression,
 				defaultScope, Statement.class.getSimpleName());
 		return interpreter.evaluateStatement(statement, context);
@@ -135,6 +136,13 @@ public class AbstractSTextTest {
 				defaultScope, Statement.class.getSimpleName());
 		return interpreter.evaluateStatement(statement, context);
 	}
+	
+	protected Object executeExpression(String scope, String expression) {
+		Scope defaultScope = createContextScope(scope);
+		Statement statement = (Statement) parseExpression(expression,
+				defaultScope, Expression.class.getSimpleName());
+		return interpreter.evaluateStatement(statement, context);
+	}
 
 	public IExecutionContext getContext() {
 		return context;

+ 7 - 0
test-plugins/org.yakindu.sct.model.sexec.interpreter.test/src/org/yakindu/sct/model/sexec/interpreter/test/STextInterpreterTest.java

@@ -625,4 +625,11 @@ public class STextInterpreterTest extends AbstractSTextTest {
 	// }
 	// }
 
+	@Test public void testPlainTrue() {
+		assertEquals(true, executeExpression("", "true"));
+	}
+	
+	@Test public void testPlainFalse() {
+		assertEquals(false, executeExpression("", "false"));
+	}
 }