use of org.eclipse.xtext.junit4.validation.AssertableDiagnostics in project statecharts by Yakindu.
the class STextJavaValidatorTest method checkNoAssignmentInGuard.
@Test
public void checkNoAssignmentInGuard() {
String scope = "internal: var myInt : integer var myBool : boolean = true";
EObject expression = super.parseExpression("[myBool = false]", ReactionTrigger.class.getSimpleName(), scope);
AssertableDiagnostics validationResult = tester.validate(expression);
validationResult.assertErrorContains(STextJavaValidator.GUARD_CONTAINS_ASSIGNMENT);
expression = super.parseExpression("[myInt = 5]", ReactionTrigger.class.getSimpleName(), scope);
validationResult = tester.validate(expression);
Iterator<Diagnostic> diag = validationResult.getAllDiagnostics().iterator();
while (diag.hasNext()) {
Diagnostic d = diag.next();
if (d.getMessage().equals(GUARD_EXPRESSION)) {
assertEquals(STextJavaValidator.GUARD_EXPRESSION, d.getMessage());
} else {
assertEquals(STextJavaValidator.GUARD_CONTAINS_ASSIGNMENT, d.getMessage());
}
}
}
use of org.eclipse.xtext.junit4.validation.AssertableDiagnostics in project statecharts by Yakindu.
the class STextJavaValidatorTest method checkReactionTrigger.
/**
* @see STextJavaValidator#checkReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger)
*/
@Test
public void checkReactionTrigger() {
// ENTRY, EXIT not allowed in transitions
String scope = "internal : event a : integer var myVar : integer";
EObject model = super.parseExpression("entry / myVar = 5", TransitionSpecification.class.getSimpleName(), scope);
AssertableDiagnostics validationResult = tester.validate(model);
validationResult.assertError(ENTRY_EXIT_TRIGGER_NOT_ALLOWED);
model = super.parseExpression("exit / myVar = 5", TransitionSpecification.class.getSimpleName(), scope);
validationResult = tester.validate(model);
validationResult.assertError(ENTRY_EXIT_TRIGGER_NOT_ALLOWED);
model = super.parseExpression("oncycle / myVar = 5", TransitionSpecification.class.getSimpleName(), scope);
validationResult = tester.validate(model);
validationResult.assertOK();
model = super.parseExpression("always / myVar = 5", TransitionSpecification.class.getSimpleName(), scope);
validationResult = tester.validate(model);
validationResult.assertOK();
}
use of org.eclipse.xtext.junit4.validation.AssertableDiagnostics in project statecharts by Yakindu.
the class STextJavaValidatorTest method testOptionalParameter.
@Test
public void testOptionalParameter() {
EObject model;
String rule = Expression.class.getSimpleName();
AssertableDiagnostics result;
model = parseExpression("optOp1()", rule);
result = tester.validate(model);
result.assertOK();
model = parseExpression("optOp1(3)", rule);
result = tester.validate(model);
result.assertOK();
model = parseExpression("optOp1(true)", rule);
result = tester.validate(model);
result.assertError(ITypeSystemInferrer.NOT_COMPATIBLE_CODE);
}
use of org.eclipse.xtext.junit4.validation.AssertableDiagnostics in project statecharts by Yakindu.
the class STextJavaValidatorTest method checkDeprecatedLocalEventDefinition.
@Test
public void checkDeprecatedLocalEventDefinition() {
String decl = "internal: local event e1";
EObject model = super.parseExpression(decl, InternalScope.class.getSimpleName());
AssertableDiagnostics result = tester.validate(model);
result.assertDiagnosticsCount(1);
result.assertWarningContains(String.format(STextJavaValidator.DECLARATION_DEPRECATED, "local"));
}
use of org.eclipse.xtext.junit4.validation.AssertableDiagnostics in project statecharts by Yakindu.
the class STextJavaValidatorTest method checkOperationArguments_TypedElementReferenceExpression.
/**
* @see STextJavaValidator#checkOperationArguments_TypedElementReferenceExpression(TypedElementReferenceExpression)
*/
@Test
public void checkOperationArguments_TypedElementReferenceExpression() {
String scope = "internal: operation myOperation(param1 : integer, param2: boolean)";
EObject model = super.parseExpression("myOperation(5,true)", Expression.class.getSimpleName(), scope);
AssertableDiagnostics validationResult = tester.validate(model);
validationResult.assertOK();
}
Aggregations