use of org.abs_models.frontend.ast.ClassDecl in project abstools by abstools.
the class DeltaAttributesBooleanTest method passFeatureAsBoolean.
@Test
public void passFeatureAsBoolean() throws DeltaModellingException, WrongProgramArgumentException {
Model model = assertParse("module M;" + "delta D(Bool f);" + "uses M;" + " adds class C { Bool myField = f; }" + "productline PL;" + " features F, G;" + " delta D(F) when G;" + "product P1(F, G);" + "product P2(G);");
model.evaluateAllProductDeclarations();
model.flattenForProduct(product);
ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
assertTrue(cls.getField(0).getName().equals("myField"));
assertTrue(cls.getField(0).getInitExp().toString().equals(expected));
}
use of org.abs_models.frontend.ast.ClassDecl in project abstools by abstools.
the class DeltaAttributesBooleanTest method passFeatureAsBoolean2.
@Test
public void passFeatureAsBoolean2() throws DeltaModellingException, WrongProgramArgumentException {
Model model = assertParse("module M;" + "delta D(Bool a, Bool b, Bool c);" + "uses M;" + " adds class C { Bool featureA = a; Bool featureB = b; Bool featureC = c; }" + "productline PL;" + " features A,B,C,F;" + " delta D(A,B,C) when F;" + "product P1(F,A);" + "product P2(F,B);" + "root F { group [0 .. *] { A, B, C } }");
model.evaluateAllProductDeclarations();
model.flattenForProduct(product);
ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
assertTrue(cls.getField(0).getName().equals("featureA"));
// assertTrue(cls.getField(1).getName().equals("featureB"));
// assertTrue(cls.getField(2).getName().equals("featureC"));
assertTrue(cls.getField(0).getInitExp().toString().equals(expected));
}
use of org.abs_models.frontend.ast.ClassDecl in project abstools by abstools.
the class DeltaAttributesBooleanTest method passBooleanFeatureAttribute.
@Test
public void passBooleanFeatureAttribute() throws DeltaModellingException, WrongProgramArgumentException {
Model model = assertParse("module M;" + "delta D(Bool attr);" + "uses M;" + "adds class C { Bool myField = attr; }" + "productline PL;" + " features F;" + " delta D(F.a) when F;" + "product P1(F{a=True});" + "product P2(F{a=False});");
model.evaluateAllProductDeclarations();
model.flattenForProduct(product);
ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
assertTrue(cls.getField(0).getName().equals("myField"));
assertTrue(cls.getField(0).getInitExp().toString().equals(expected));
}
use of org.abs_models.frontend.ast.ClassDecl in project abstools by abstools.
the class DeltaAttributesBooleanTest method passBooleanConstant.
@Test
public void passBooleanConstant() throws DeltaModellingException, WrongProgramArgumentException {
Model model = assertParse("module M;" + "delta D(Bool attr);" + "uses M;" + " adds class C { Bool myField = attr; }" + "productline PL;" + " features A,B;" + " delta D(True) when A;" + " delta D(False) when B;" + "product P1(A);" + "product P2(B);");
model.evaluateAllProductDeclarations();
model.flattenForProduct(product);
ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
assertEquals("myField", cls.getField(0).getName());
assertEquals("Product " + product, expected, cls.getField(0).getInitExp().toString());
}
use of org.abs_models.frontend.ast.ClassDecl in project abstools by abstools.
the class DeltaAttributesMixedTest method passBooleanFeatureAttributes1b.
@Test
public void passBooleanFeatureAttributes1b() throws DeltaModellingException, WrongProgramArgumentException {
Model model = assertParse("module M;" + "delta D(Bool a1, Int a2);" + "uses M;" + " adds class C { Bool first = a1; Int second = a2; }" + "productline PL;" + " features F;" + " delta D(F.a, F.b) when F;" + "product P1( F{a=True, b=3} );", Config.TYPE_CHECK);
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("IntLiteral(3)", cls.getField(1).getInitExp().toString());
}
Aggregations