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

Added test case for checkVariableDefinitionInitialValue

Andreas Mülder 14 лет назад
Родитель
Сommit
93b67dfca9

+ 16 - 0
test-plugins/org.yakindu.sct.model.stext.test/src/org/yakindu/sct/model/stext/test/STextJavaValidatorTest.java

@@ -151,6 +151,22 @@ public class STextJavaValidatorTest extends AbstractSTextTest {
 		// Nothing to do, checked by Typeanalyzer tests
 		// Nothing to do, checked by Typeanalyzer tests
 	}
 	}
 
 
+	@Test
+	public void checkVariableDefinitionInitialValue() {
+		// Success
+		EObject model = super.parseExpression(
+				"interface: var myBool : boolean = !true", null,
+				StatechartSpecification.class.getSimpleName());
+		AssertableDiagnostics result = tester.validate(model);
+		result.assertDiagnosticsCount(0);
+		// Fail
+		model = super.parseExpression("interface: var myBool : boolean = 5",
+				null, StatechartSpecification.class.getSimpleName());
+		result = tester.validate(model);
+		result.assertDiagnosticsCount(1);
+		result.assertErrorContains("Can not assign a value of type 'integer' to a variable of type 'boolean'");
+	}
+
 	/**
 	/**
 	 * checks tht each @Check method of {@link STextJavaValidator} has a @Test
 	 * checks tht each @Check method of {@link STextJavaValidator} has a @Test
 	 * method in this class with the same name
 	 * method in this class with the same name