use of org.eclipse.xtext.junit4.validation.AssertableDiagnostics in project statecharts by Yakindu.
the class STextJavaValidatorTest method checkAssignmentExpression.
/**
* @see STextJavaValidator#checkAssignmentExpression(org.yakindu.sct.model.stext.stext.AssignmentExpression)
*/
@Test
public void checkAssignmentExpression() {
String context = "interface: var i : integer = 42 var j : integer =23";
EObject expression = super.parseExpression("i += (i+=3) +4", Expression.class.getSimpleName(), context);
AssertableDiagnostics validationResult = tester.validate(expression);
validationResult.assertErrorContains(STextJavaValidator.ASSIGNMENT_EXPRESSION);
expression = super.parseExpression("i += (j+=3) +4", Expression.class.getSimpleName(), context);
validationResult = tester.validate(expression);
validationResult.assertOK();
}
use of org.eclipse.xtext.junit4.validation.AssertableDiagnostics in project statecharts by Yakindu.
the class STextJavaValidatorTest method checkReactionEffectActions.
/**
* @see STextJavaValidator#checkReactionEffectActions(org.yakindu.sct.model.stext.stext.ReactionEffect)
*/
@Test
public void checkReactionEffectActions() {
String s1 = "internal : var a : integer event e operation o () : void";
String s2 = "interface if : var a : integer in event e operation o()";
EObject model = super.parseExpression("a", ReactionEffect.class.getSimpleName(), s1);
AssertableDiagnostics result = tester.validate(model);
result.assertError(FEATURE_CALL_HAS_NO_EFFECT);
model = super.parseExpression("1+3", ReactionEffect.class.getSimpleName(), s1);
result = tester.validate(model);
result.assertError(FEATURE_CALL_HAS_NO_EFFECT);
model = super.parseExpression("valueof(e)", ReactionEffect.class.getSimpleName(), s1);
result = tester.validate(model);
result.assertError(FEATURE_CALL_HAS_NO_EFFECT);
model = super.parseExpression("o()", ReactionEffect.class.getSimpleName(), s1);
result = tester.validate(model);
result.assertOK();
model = super.parseExpression("if.a", ReactionEffect.class.getSimpleName(), s2);
result = tester.validate(model);
result.assertError(FEATURE_CALL_HAS_NO_EFFECT);
model = super.parseExpression("valueof(if.e)", ReactionEffect.class.getSimpleName(), s2);
result = tester.validate(model);
result.assertError(FEATURE_CALL_HAS_NO_EFFECT);
model = super.parseExpression("if.o", ReactionEffect.class.getSimpleName(), s2);
result = tester.validate(model);
result.assertOK();
}
use of org.eclipse.xtext.junit4.validation.AssertableDiagnostics in project statecharts by Yakindu.
the class STextJavaValidatorTest method checkValueOfNoEvent.
@Test
public void checkValueOfNoEvent() {
String decl = "interface: in event e1:integer var x:integer operation op():integer interface i: in event e2:integer var y:integer";
EObject model = super.parseExpression("valueof(e1)", Expression.class.getSimpleName(), decl);
AssertableDiagnostics result = tester.validate(model);
result.assertOK();
model = super.parseExpression("valueof(i.e2)", Expression.class.getSimpleName(), decl);
result = tester.validate(model);
result.assertOK();
model = super.parseExpression("valueof(x)", Expression.class.getSimpleName(), decl);
result = tester.validate(model);
result.assertError(VALUE_OF_REQUIRES_EVENT);
model = super.parseExpression("valueof(i.y)", Expression.class.getSimpleName(), decl);
result = tester.validate(model);
result.assertError(VALUE_OF_REQUIRES_EVENT);
model = super.parseExpression("valueof(op())", Expression.class.getSimpleName(), decl);
result = tester.validate(model);
result.assertError(VALUE_OF_REQUIRES_EVENT);
}
use of org.eclipse.xtext.junit4.validation.AssertableDiagnostics in project statecharts by Yakindu.
the class STextJavaValidatorTest method testMultipleOptionalParameters.
@Test
public void testMultipleOptionalParameters() {
EObject model;
String rule = Expression.class.getSimpleName();
AssertableDiagnostics result;
model = parseExpression("optOp2()", rule);
result = tester.validate(model);
result.assertOK();
model = parseExpression("optOp2(3)", rule);
result = tester.validate(model);
result.assertOK();
model = parseExpression("optOp2(3, 4)", rule);
result = tester.validate(model);
result.assertOK();
model = parseExpression("optOp2(true)", rule);
result = tester.validate(model);
result.assertError(ITypeSystemInferrer.NOT_COMPATIBLE_CODE);
model = parseExpression("optOp2(true, 3, 4)", rule);
result = tester.validate(model);
result.assertAll(errorCode(ITypeSystemInferrer.NOT_COMPATIBLE_CODE), errorCode(ERROR_WRONG_NUMBER_OF_ARGUMENTS_CODE));
}
use of org.eclipse.xtext.junit4.validation.AssertableDiagnostics in project statecharts by Yakindu.
the class STextJavaValidatorTest method checkRaisingExpressionEvent.
@Test
public void checkRaisingExpressionEvent() {
String scope = "interface : in event e var x : integer var y : integer operation op():integer";
EObject model = super.parseExpression("raise e", ReactionEffect.class.getSimpleName(), scope);
AssertableDiagnostics validationResult = tester.validate(model);
validationResult.assertOK();
model = super.parseExpression("raise y", ReactionEffect.class.getSimpleName(), scope);
validationResult = tester.validate(model);
validationResult.assertAll(errorMsg("'y' is not an event."));
}
Aggregations