Java Code Examples for org.eclipse.xtext.junit4.validation.AssertableDiagnostics#assertAll()
The following examples show how to use
org.eclipse.xtext.junit4.validation.AssertableDiagnostics#assertAll() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: STextValidatorTest.java From statecharts with Eclipse Public License 1.0 | 6 votes |
@Test public void checkReactionTriggerRegularEvent() { String scope = "interface : in event e var x : integer var y : integer operation op():integer"; EObject model = super.parseExpression("e", TransitionSpecification.class.getSimpleName(), scope); AssertableDiagnostics validationResult = tester.validate(model); validationResult.assertOK(); model = super.parseExpression("x", TransitionSpecification.class.getSimpleName(), scope); validationResult = tester.validate(model); validationResult.assertError(TRIGGER_IS_NO_EVENT); model = super.parseExpression("e, x", TransitionSpecification.class.getSimpleName(), scope); validationResult = tester.validate(model); validationResult.assertError(TRIGGER_IS_NO_EVENT); model = super.parseExpression("op()", TransitionSpecification.class.getSimpleName(), scope); validationResult = tester.validate(model); validationResult.assertError(TRIGGER_IS_NO_EVENT); model = super.parseExpression("x, y", TransitionSpecification.class.getSimpleName(), scope); validationResult = tester.validate(model); validationResult.assertAll(errorMsg("Trigger 'x' is no event."), errorMsg("Trigger 'y' is no event.")); }
Example 2
Source File: XsemanticsValidatorTests.java From xsemantics with Eclipse Public License 1.0 | 5 votes |
@Test public void testNoAuxFunForAuxiliaryDescription() throws Exception { validator.setEnableWarnings(true); AssertableDiagnostics validate = loadModelAndValidate(testFiles .testAuxiliaryDescriptionsWithoutAuxFun()); validate.assertAll( AssertableDiagnostics .warningMsg("No function defined for the auxiliary description"), AssertableDiagnostics .warningMsg("No function defined for the auxiliary description"), AssertableDiagnostics .warningMsg("No function defined for the auxiliary description")); }
Example 3
Source File: XsemanticsValidatorTests.java From xsemantics with Eclipse Public License 1.0 | 5 votes |
@Test public void testWrongReturnInPremises() throws Exception { AssertableDiagnostics validate = loadModelAndValidate(testFiles .testWrongReturnInPremises()); validate.assertAll( AssertableDiagnostics.error(RETURN_NOT_ALLOWED, "Return statements are not allowed here")); // in 2.4 the next error is not issued // AssertableDiagnostics // .error(org.eclipse.xtext.xbase.validation.INCOMPATIBLE_TYPES, // "Incompatible types")); }
Example 4
Source File: XsemanticsValidatorTests.java From xsemantics with Eclipse Public License 1.0 | 5 votes |
@Test public void testAccessToOutputParamInsideClosure() throws Exception { AssertableDiagnostics validate = loadModelAndValidate(testFiles .testAccessToOutputParamInsideClosure()); validate.assertAll(AssertableDiagnostics .error(ACCESS_TO_OUTPUT_PARAM_WITHIN_CLOSURE, "Cannot refer to an output parameter eC from within a closure")); }
Example 5
Source File: XsemanticsValidatorTests.java From xsemantics with Eclipse Public License 1.0 | 5 votes |
@Test public void testRuleInvocationWithOutputArgInsideClosure() throws Exception { AssertableDiagnostics validate = loadModelAndValidate(testFiles .testRuleInvocationWithOutputArgInsideClosure()); validate.assertAll(AssertableDiagnostics .error(ACCESS_TO_OUTPUT_PARAM_WITHIN_CLOSURE, "Cannot refer to an output parameter eC from within a closure")); }
Example 6
Source File: XsemanticsValidatorTests.java From xsemantics with Eclipse Public License 1.0 | 5 votes |
@Test public void testWrongVariableDeclarationAsInputArgument() throws Exception { AssertableDiagnostics validate = loadModelAndValidate(testFiles .testWrongVariableDeclarationAsInputArgument()); validate.assertAll(AssertableDiagnostics.error( NOT_VALID_INPUT_ARG, "Not a valid argument for input parameter")); }
Example 7
Source File: XsemanticsValidatorTests.java From xsemantics with Eclipse Public License 1.0 | 5 votes |
protected void assertDuplicateErrors(AssertableDiagnostics validate, String elementClassName, String duplicateName, String... msgFragments) { //System.out.println(diagnosticsToString(validate)); String messageFragment = "Duplicate " + elementClassName + " '" + duplicateName + "'"; validate.assertAll(AssertableDiagnostics.errorMsg(messageFragment), AssertableDiagnostics.errorMsg(messageFragment)); for (String msgFragment : msgFragments) { validate.assertAny(AssertableDiagnostics.errorMsg(msgFragment)); } }
Example 8
Source File: XsemanticsValidatorTests.java From xsemantics with Eclipse Public License 1.0 | 5 votes |
@Test public void testNoInputParam() throws Exception { AssertableDiagnostics validate = loadModelAndValidate(testFiles .testJudgmentDescriptionsWithNoInputParam()); validate.assertAll(AssertableDiagnostics.error( NO_INPUT_PARAM, "No input parameter; at least one is needed")); }
Example 9
Source File: XsemanticsValidatorTests.java From xsemantics with Eclipse Public License 1.0 | 5 votes |
@Test public void testMoreThan3OutputParams() throws Exception { AssertableDiagnostics validate = loadModelAndValidate(testFiles .testJudgmentDescriptionsWith4OutputParams()); validate.assertAll(AssertableDiagnostics.error( TOO_MANY_OUTPUT_PARAMS, "No more than 3 output parameters are handled at the moment")); }
Example 10
Source File: XsemanticsValidatorTests.java From xsemantics with Eclipse Public License 1.0 | 5 votes |
@Test public void testRulesOfTheSameKindWithSameInputArgumentTypes() throws Exception { AssertableDiagnostics validate = loadModelAndValidate(testFiles .testRulesOfTheSameKindWithSameInputArgumentTypes()); validate.assertAll(AssertableDiagnostics.error( DUPLICATE_RULE_WITH_SAME_ARGUMENTS, "Duplicate rule of the same kind with parameters: String" + IN_SYSTEM_ORG_ECLIPSE_XSEMANTICS_TEST_TYPE_SYSTEM), AssertableDiagnostics.error( DUPLICATE_RULE_WITH_SAME_ARGUMENTS, "Duplicate rule of the same kind with parameters: String" + IN_SYSTEM_ORG_ECLIPSE_XSEMANTICS_TEST_TYPE_SYSTEM)); }
Example 11
Source File: XsemanticsValidatorTests.java From xsemantics with Eclipse Public License 1.0 | 5 votes |
@Test public void testSystemExtendsInvalidBaseSystem() throws Exception { AssertableDiagnostics validate = loadModelAndValidate(testFiles .testSystemExtendsInvalidBaseSystem()); validate.assertAll(AssertableDiagnostics .error(NOT_VALID_SUPER_SYSTEM, "Not an Xsemantics system: TestInvalidBaseSystem")); }
Example 12
Source File: XsemanticsValidatorTests.java From xsemantics with Eclipse Public License 1.0 | 5 votes |
@Test public void testNoRuleForJudgmentDescription() throws Exception { validator.setEnableWarnings(true); AssertableDiagnostics validate = loadModelAndValidate(testFiles .testJudgmentDescriptions()); validate.assertAll(AssertableDiagnostics .warningMsg("No rule defined for the judgment description")); }
Example 13
Source File: XsemanticsValidatorTests.java From xsemantics with Eclipse Public License 1.0 | 5 votes |
@Test public void testRulesWithExpressionInConclusionWrong() throws Exception { AssertableDiagnostics validate = loadModelAndValidate(testFiles .testRuleWithExpressionInConclusion2()); validate.assertAll(AssertableDiagnostics.error( NOT_PARAMETER, "Must be a parameter, not an expression")); }
Example 14
Source File: XsemanticsValidatorTests.java From xsemantics with Eclipse Public License 1.0 | 5 votes |
@Test public void testDuplicateJudgmentDescriptionSymbols() throws Exception { AssertableDiagnostics validate = loadModelAndValidate(testFiles .testJudgmentDescriptionsWithDuplicateSymbols()); String messageFragment = "Duplicate judgment symbols '|- :'"; validate.assertAll(AssertableDiagnostics.error( DUPLICATE_JUDGMENT_DESCRIPTION_SYMBOLS, messageFragment), AssertableDiagnostics.error( DUPLICATE_JUDGMENT_DESCRIPTION_SYMBOLS, messageFragment)); }
Example 15
Source File: STextValidatorTest.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@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)); }
Example 16
Source File: XsemanticsValidatorTests.java From xsemantics with Eclipse Public License 1.0 | 5 votes |
@Test public void testWrongThrowInPremises() throws Exception { AssertableDiagnostics validate = loadModelAndValidate(testFiles .testWrongThrowInPremises()); validate.assertAll(AssertableDiagnostics.error( THROW_NOT_ALLOWED, "Throw statements are not allowed here")); // AssertableDiagnostics // .error(org.eclipse.xtext.xbase.validation.UNHANDLED_EXCEPTION, // "Unhandled exception")); }
Example 17
Source File: STextValidatorTest.java From statecharts with Eclipse Public License 1.0 | 5 votes |
/** * @see STextValidator#checkInterfaceScope(Statechart) */ @Test public void checkInterfaceScope() { EObject model = super.parseExpression("interface: in event event1 interface: in event event2", StatechartSpecification.class.getSimpleName()); AssertableDiagnostics result = tester.validate(model); result.assertDiagnosticsCount(2); result.assertAll(errorCode(ONLY_ONE_INTERFACE), errorCode(ONLY_ONE_INTERFACE)); }
Example 18
Source File: STextValidatorTest.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@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.")); }
Example 19
Source File: FjAbstractGeneratedValidatorTests.java From xsemantics with Eclipse Public License 1.0 | 4 votes |
protected void assertAll(AssertableDiagnostics validate, DiagnosticPredicate... predicates) { System.err.println(utils.diagnosticsToString(validate)); validate.assertAll(predicates); }
Example 20
Source File: STextValidatorTest.java From statecharts with Eclipse Public License 1.0 | 4 votes |
@Test public void testDuplicateNames() { EObject model; AssertableDiagnostics result; String scope; scope = "interface: var x: integer var x: integer"; model = super.parseExpression(scope, StatechartSpecification.class.getSimpleName()); result = tester.validate(model); result.assertAll(errorMsg("Duplicate"), errorMsg("Duplicate")); scope = "interface: var x: integer internal: var x: integer"; model = super.parseExpression(scope, StatechartSpecification.class.getSimpleName()); result = tester.validate(model); result.assertAll(errorMsg("Duplicate"), errorMsg("Duplicate")); scope = "interface: var x: integer interface d: var x: integer"; model = super.parseExpression(scope, StatechartSpecification.class.getSimpleName()); result = tester.validate(model); result.assertOK(); scope = "interface: var x: integer interface x: var d: integer"; model = super.parseExpression(scope, StatechartSpecification.class.getSimpleName()); result = tester.validate(model); result.assertAll(errorMsg("Duplicate"), errorMsg("Duplicate")); scope = "interface: var x: integer var X: integer"; model = super.parseExpression(scope, StatechartSpecification.class.getSimpleName()); result = tester.validate(model); result.assertAll(warningMsg("Duplicate"), warningMsg("Duplicate")); scope = "interface: var x: integer interface X: var d: integer"; model = super.parseExpression(scope, StatechartSpecification.class.getSimpleName()); result = tester.validate(model); result.assertOK(); scope = "interface: " + "var X: integer " + "var x: integer " + "" + "var d: integer " + " " + "interface D: " + "var x: integer " + " " + "interface x: " + "var i: integer"; model = super.parseExpression(scope, StatechartSpecification.class.getSimpleName()); result = tester.validate(model); result.assertAll(warningMsg("Duplicate"), warningMsg("Duplicate"), errorMsg("Duplicate"), errorMsg("Duplicate")); }