use of org.abs_models.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class ProductLineTypeAnalysisTest method stronglyUnambiguousProductLine1.
@Test
public void stronglyUnambiguousProductLine1() {
Model model = assertParse("module M;" + "delta D1; uses M; modifies class C { adds Unit foo() {} }" + "delta D2; modifies class M.C { adds Unit foo() {} }" + "productline PL;" + "features A;" + "delta D1;" + "delta D2 after D1;");
ProductLine pl = model.getProductLine();
SemanticConditionList errors = new SemanticConditionList();
assertTrue(ProductLineAnalysisHelper.isStronglyUnambiguous(pl, errors));
assertEquals(0, errors.getErrorCount());
}
use of org.abs_models.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class ProductLineTypeAnalysisTest method stronglyUnambiguousProductLine5.
@Test
public void stronglyUnambiguousProductLine5() {
Model model = assertParse("module M;" + "delta D1; uses M; adds class C {}" + "delta D2; uses M; removes class C;" + "productline PL;" + "features A;" + "delta D1;" + "delta D2;");
ProductLine pl = model.getProductLine();
SemanticConditionList errors = new SemanticConditionList();
/* Both deltas are in same partition (no order specified)
* Both deltas act on the same class C
*/
assertFalse(ProductLineAnalysisHelper.isStronglyUnambiguous(pl, errors));
assertEquals(1, errors.getErrorCount());
}
use of org.abs_models.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class ProductLineTypeAnalysisTest method stronglyUnambiguousProductLinePerformance.
@Test
public void stronglyUnambiguousProductLinePerformance() {
Model model = assertParse("module M; class C {}");
CompilationUnit cu = new CompilationUnit();
model.addCompilationUnit(cu);
ProductLine pl = new ProductLine();
pl.setName("PL");
cu.setProductLine(pl);
int n = 2000;
for (int i = 0; i < n; i++) {
String id = Integer.toHexString(UUID.randomUUID().hashCode());
ModifyClassModifier cmod = new ModifyClassModifier();
cmod.setName("C");
MethodSig msig = new MethodSig();
msig.setName("m" + id);
MethodImpl mimpl = new MethodImpl();
mimpl.setMethodSig(msig);
org.abs_models.frontend.ast.List<MethodImpl> list = new org.abs_models.frontend.ast.List<>();
list.add(mimpl);
DeltaTraitModifier dmod = new DeltaTraitModifier(new ModifyMethodModifier(new TraitSetExpr(list)));
cu.addDeltaDecl(new DeltaDecl("D" + id, new org.abs_models.frontend.ast.List<>(), new org.abs_models.frontend.ast.Opt<>(), new org.abs_models.frontend.ast.List<>(cmod)));
DeltaClause dc = new DeltaClause();
Deltaspec dspec = new Deltaspec();
dspec.setDeltaID("D" + id);
dc.setDeltaspec(dspec);
pl.addDeltaClause(dc);
}
pl = model.getProductLine();
SemanticConditionList errors = new SemanticConditionList();
long startTime = System.currentTimeMillis();
assertTrue(ProductLineAnalysisHelper.isStronglyUnambiguous(pl, errors));
long stopTime = System.currentTimeMillis();
// System.out.println(n + " deltas. time (ms): " + (stopTime - startTime));
}
use of org.abs_models.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class ProductDeclarationTest method invalidProduct.
@Test
public void invalidProduct() throws WrongProgramArgumentException {
Model model = assertParse("product P1 = {F1, F2};" + "root FM {" + "group allof { F1, F2, F3 }" + "}");
model.evaluateAllProductDeclarations();
ProductDecl p = model.findProduct("P1");
SemanticConditionList e = new SemanticConditionList();
typeCheck(model, p, e);
assertEquals(1, e.getErrorCount());
assertEquals(ErrorMessage.INVALID_PRODUCT, e.getFirstError().msg);
}
use of org.abs_models.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class ProgramAbstractionTest method removeClass.
@Test
public void removeClass() {
Model model = assertParse("module M;" + "class C(Rat myParam) { Int myField = 99; Int myMethod(String a, Bool b) { return 88; } }" + "delta D;" + "uses M;" + "removes class C;" + "productline PL;" + "features F;" + "delta D when F;" + "root FM { group allof { opt F } }");
SemanticConditionList errors = new SemanticConditionList();
ProductLine pl = model.getProductLine();
DeltaTrie trie = ProductLineAnalysisHelper.buildPFGT(pl, errors);
ProgramAbstraction pa = trie.getRoot().getChildren().get("D").getProgramAbstraction();
System.out.println("******\n" + pa);
assertFalse(pa.getClasses().containsKey("M.C"));
}
Aggregations