use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class ASTBasedABSTestRunnerGeneratorTest method testGenerateTestRunner.
@Test
public final void testGenerateTestRunner() {
final Model model;
try {
model = Main.parseString(ABS_UNIT + TEST_CODE, true);
} catch (Exception e) {
throw new IllegalStateException("Cannot parse test code", e);
}
ABSTestRunnerGenerator generator = new ASTBasedABSTestRunnerGenerator(model);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
PrintStream print = new PrintStream(stream);
generator.generateTestRunner(print);
String runner = stream.toString();
try {
Model result = Main.parseString(ABS_UNIT + TEST_CODE + runner, true);
StringBuilder parseErrors = new StringBuilder();
if (result.hasParserErrors()) {
parseErrors.append("Syntactic errors: ");
List<ParserError> es = result.getParserErrors();
parseErrors.append(es.size());
parseErrors.append("\n");
for (ParserError e : es) {
parseErrors.append(e.getHelpMessage());
parseErrors.append("\n");
}
}
assertFalse("Generated code must not have parse error: " + parseErrors, result.hasParserErrors());
StringBuilder errors = new StringBuilder();
if (result.hasErrors()) {
SemanticConditionList el = result.getErrors();
errors.append("Semantic errors: ");
errors.append(el.getErrorCount());
errors.append("\n");
for (SemanticCondition error : el) {
errors.append(error.getHelpMessage());
errors.append("\n");
}
}
assertFalse("Generated code must not have semantic error: " + errors, result.hasErrors());
result.typeCheck();
assertFalse("Generated code must not have type error", result.hasTypeErrors());
assertThat("Has one module that has the name 'AbsUnit.TestRunner' and a main block", result.getModuleDecls(), hasItem(new ModuleMatcher()));
} catch (Exception e) {
fail("Cannot throw an exception ");
}
}
use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class ParFnAppTest method tooFewArgsForFuncParam.
@Test
public void tooFewArgsForFuncParam() {
Model m = parse("apply(tooMany)(0);", applyFunction(), "def Int tooMany(Int i, Int j) = 0;");
m.expandPartialFunctions();
SemanticConditionList conditions = m.typeCheck();
assertTrue(conditions.containsErrors());
}
use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class LocationTypeTests method testAwaitFail.
@Test
public void testAwaitFail() {
LocationType lt = LocationType.INFER;
Model m = assertParseOkStdLib("interface T { Unit foo(); } class C { T t = null; Unit bar() { await t!foo(); }}");
// This line is essential to trigger the NPE!
assertFalse(m.hasErrors());
LocationTypeInferrerExtension ltie = new LocationTypeInferrerExtension(m);
ltie.setDefaultType(lt);
ltie.setLocationTypingPrecision(LocationTypingPrecision.CLASS_LOCAL_FAR);
m.registerTypeSystemExtension(ltie);
m.getErrors();
SemanticConditionList e = m.typeCheck();
}
use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class LocationTypeTests method assertLocationTypeErrorOnly.
private void assertLocationTypeErrorOnly(String code) {
Model m = assertParse(code, WITH_STD_LIB);
LocationTypeExtension te = new LocationTypeExtension(m);
m.registerTypeSystemExtension(te);
SemanticConditionList e = m.typeCheck();
assertFalse("No type error occurred", !e.containsErrors());
assertInferFails(code);
}
use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class LocationTypeTests method assertTypeOkOnly.
private void assertTypeOkOnly(String code) {
Model m = assertParse(code, WITH_STD_LIB);
LocationTypeExtension te = new LocationTypeExtension(m);
m.registerTypeSystemExtension(te);
m.getErrors();
SemanticConditionList e = m.typeCheck();
assertTrue(!e.containsErrors() ? "" : "Found error " + e.getFirstError().getMessage(), !e.containsErrors());
assertInferOk(code);
}
Aggregations