Просмотр исходного кода

Added NullLiteral to Interpreter

Andreas Mülder 12 лет назад
Родитель
Сommit
d8a85852ea

+ 5 - 1
plugins/org.yakindu.sct.simulation.core.sexec/src/org/yakindu/sct/simulation/core/sexec/interpreter/StextStatementInterpreter.xtend

@@ -44,7 +44,8 @@ import org.yakindu.sct.model.stext.stext.EventDefinition
 import org.yakindu.sct.model.stext.stext.EventRaisingExpression
 import org.yakindu.sct.model.stext.stext.EventValueReferenceExpression
 import org.yakindu.sct.simulation.core.sruntime.ExecutionContext
-
+import org.yakindu.base.expressions.expressions.NullLiteral
+
 /**
  * 
  * @author andreas muelder - Initial contribution and API 
@@ -273,6 +274,9 @@ class StextStatementInterpreter extends AbstractStatementInterpreter {
 
 	def dispatch valueLiteral(StringLiteral literal) {
 		return literal.value
+	}
+	def dispatch valueLiteral(NullLiteral literal) {
+		return null
 	}
 
 }

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

@@ -84,6 +84,12 @@ public class STextInterpreterTest extends AbstractSTextTest {
 		executeWithDefaultScope("stringVar = 'fortytwo'");
 		assertEquals("fortytwo", getStringValue());
 	}
+	
+	@Test
+	public void testStringNullAssignment() {
+		executeWithDefaultScope("stringVar = null");
+		assertEquals(null, getStringValue());
+	}
 
 	@Test
 	public void testConditionalTrue() {