use of edu.uah.rsesc.aadlsimulator.xtext.util.ReferenceTypeResolver in project AGREE by loonwerks.
the class TestGrammar method testConstraint.
private static void testConstraint(final String constraint, final ResultType expectedType, final int numberOfPreviousSteps, final boolean isConstraintValid) {
com.google.inject.Injector injector = new InputConstraintStandaloneSetup().createInjectorAndDoEMFRegistration();
final InputConstraintHelper parserHelper = injector.getInstance(InputConstraintHelper.class);
final ReferenceTypeResolver refResolver = new TestReferenceTypeResolver();
final InputConstraintHelper.Result parseAndValidateResult = parserHelper.parseAndValidate(constraint, refResolver, expectedType, numberOfPreviousSteps);
if (parseAndValidateResult.isValid()) {
if (isConstraintValid) {
System.out.println("Success: Constructed AST for constraint: " + constraint + " : " + parseAndValidateResult.getInputConstraint());
// Try to unparse the constraint
parserHelper.unparse(parseAndValidateResult.getInputConstraint());
} else {
System.err.println("Error: Invalid constraint: " + constraint + " passed test.");
}
} else {
if (isConstraintValid) {
System.err.println("Error: Failed to create AST from constraint: " + constraint + ". " + parseAndValidateResult.getErrorMessage());
} else {
System.out.println("Success: Expected error for : " + constraint + " : " + parseAndValidateResult.getErrorMessage());
}
}
}
Aggregations