use of org.abs_models.frontend.ast.ClassDecl in project abstools by abstools.
the class DeltaAttributesMixedTest method passBooleanFeatureAttributes1.
@Test
public void passBooleanFeatureAttributes1() throws DeltaModellingException, WrongProgramArgumentException {
Model model = assertParse("module M;" + "delta D(Bool a1, Bool a2);" + "uses M;" + " adds class C { Bool first = a1; Bool second = a2; }" + "productline PL;" + " features F;" + " delta D(F.a, F.b) when F;" + "product P1( F{a=True, b=False} );");
model.evaluateAllProductDeclarations();
model.flattenForProduct("P1");
ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
assertEquals("first", cls.getField(0).getName());
assertEquals("True()", cls.getField(0).getInitExp().toString());
assertEquals("second", cls.getField(1).getName());
assertEquals("False()", cls.getField(1).getInitExp().toString());
}
use of org.abs_models.frontend.ast.ClassDecl in project abstools by abstools.
the class DeltaAttributesMixedTest method passBooleanFeatureAttributes2.
@Test
public void passBooleanFeatureAttributes2() throws DeltaModellingException, WrongProgramArgumentException {
Model model = assertParse("module M;" + "delta D(Bool attr);" + "uses M;" + " adds class C { Bool attr = attr; Unit m() {Bool x = attr;} }" + "productline PL;" + " features F; delta D(F.a) when F;" + "product P1( F{a=True} );");
model.evaluateAllProductDeclarations();
model.flattenForProduct("P1");
ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
assertEquals("attr", cls.getField(0).getName());
assertEquals("True()", cls.getField(0).getInitExp().toString());
// TODO test the value of x
}
use of org.abs_models.frontend.ast.ClassDecl in project abstools by abstools.
the class DeltaAttributesMixedTest method passFeaturesAsBooleans.
@Test
public void passFeaturesAsBooleans() throws DeltaModellingException, WrongProgramArgumentException {
Model model = assertParse("module M;" + "delta D(Bool a, Bool b, Bool c, Int c_a1);" + "uses M;" + " adds class C { " + " Bool fA = a; " + " Bool fB = b; " + " Bool fC = c; " + " Int fC_a1 = c_a1; " + " }" + "productline PL;" + " features A,B,C;" + " delta D(A, B, C, C.a1) when C;" + "product P1( C{a1=99} );");
model.evaluateAllProductDeclarations();
model.flattenForProduct("P1");
ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
assertEquals("fA", cls.getField(0).getName());
assertEquals("False()", cls.getField(0).getInitExp().toString());
assertEquals("fB", cls.getField(1).getName());
assertEquals("False()", cls.getField(1).getInitExp().toString());
assertEquals("fC", cls.getField(2).getName());
assertEquals("True()", cls.getField(2).getInitExp().toString());
assertEquals("fC_a1", cls.getField(3).getName());
assertEquals("IntLiteral(99)", cls.getField(3).getInitExp().toString());
}
use of org.abs_models.frontend.ast.ClassDecl in project abstools by abstools.
the class VarResolutionTest method testFieldUse.
@Test
public void testFieldUse() {
Model m = assertParse(" class C { Bool f; Bool m() { return this.f; } }");
ClassDecl d = (ClassDecl) getTestModule(m).lookup(new KindedName(KindedName.Kind.CLASS, "UnitTest.C"));
FieldDecl f = d.getField(0);
ReturnStmt s = (ReturnStmt) d.getMethod(0).getBlock().getStmt(0);
assertEquals(f, ((FieldUse) s.getRetExp()).getDecl());
}
Aggregations