use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class LocationTypeTests method writeBackSolutions.
private String writeBackSolutions(String code) throws Exception {
File f = File.createTempFile("test", ".abs");
f.deleteOnExit();
FileWriter fw = new FileWriter(f);
fw.write(code);
fw.close();
Model m = assertParseFileOk(f.getAbsolutePath(), Config.WITH_STD_LIB);
LocationTypeInferrerExtension ltie = new LocationTypeInferrerExtension(m);
m.registerTypeSystemExtension(ltie);
SemanticConditionList e = m.typeCheck();
assertEquals(!e.containsErrors() ? "" : "Found error: " + e.getFirstError().getMessage(), false, e.containsErrors());
new InferMain().writeInferenceResultsBack(ltie.getResults());
String res = FileUtils.fileToStringBuilder(f).toString();
f.delete();
return res;
}
use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class LocationTypeTests method assertInfer.
private Model assertInfer(String code, LocationType expected, boolean fails) {
Model m = assertParse(code, WITH_STD_LIB);
// m.setLocationTypingEnabled(true);
LocationTypeInferrerExtension ltie = new LocationTypeInferrerExtension(m);
m.registerTypeSystemExtension(ltie);
SemanticConditionList e = m.typeCheck();
// System.out.println(ltie.getConstraints());
assertEquals(!e.containsErrors() ? "" : "Found error: " + e.getFirstError().getMessage(), fails, e.containsErrors());
// assertEquals(fails, generated == null);
if (expected != null) {
VarDeclStmt vds = ((VarDeclStmt) m.getMainBlock().getStmt(0));
LocationType t = ltie.getResults().get(LocationTypeInferrerExtension.getLV(vds.getVarDecl().getType()));
assertTrue(t.toString(), expected == LocationType.FAR ? t == LocationType.FAR || t.isParametricFar() : expected == t);
}
return m;
}
use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class PardefTest method expand.
protected final Model expand(Model model) {
try {
model.flattenTraitOnly();
model.expandPartialFunctions();
SemanticConditionList e = model.typeCheck();
assertFalse("Type check errors! First: " + e.getFirstError(), e.containsErrors());
return model;
} catch (Throwable e) {
if (e instanceof PardefModellingException) {
// prettyprint could fail if expansion left the AST in an invalid state
throw e;
}
PrintWriter pw = new PrintWriter(System.out);
model.lookupModule("UnitTest").doPrettyPrint(pw, new DefaultABSFormatter(pw));
pw.flush();
throw e;
}
}
use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class DeltaSamplesTest method test_ticket329.
@Test
public void test_ticket329() throws Exception {
Model m = assertParseFileOk("tests/abssamples/deltas/bug329.abs", true);
SemanticConditionList errs = m.typeCheck();
/* We are expecting a missing delta in product M.PL: */
assertThat(errs.getFirstError(), instanceOf(TypeError.class));
TypeError te = (TypeError) errs.getFirstError();
Assert.assertEquals(ErrorMessage.NAME_NOT_RESOLVABLE, te.msg);
}
use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class DeltaTrieTest method trieContent.
@Test
public void trieContent() {
// TODO
Model model = assertParseOk("module Test;" + "class Ccore{}" + "delta D1; uses Test; adds class C1 {Int f1 = 0; Unit m1() {}}" + "delta D2; uses Test; adds class C2 {Int f2 = 0; Unit m2() {}}" + "delta D3;" + // + " modifies class Test.C2 { adds Int f2a = 1; modifies Unit m2() {} adds Unit m2a() {} }"
"" + "" + "" + "" + "productline PL;" + "features A,B;" + "delta D1 when A;" + "delta D2 after D1 when B;" + "delta D3 after D1,D2 when A && B;" + "root FM {" + " group [1..*] { A, B }" + "}");
ProductLine pl = model.getProductLine();
DeltaTrie pfgt = ProductLineAnalysisHelper.buildPFGT(pl, new SemanticConditionList());
// TODO: tests
}
Aggregations