Search in sources :

Example 71 with ClassDecl

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));
}
Also used : ClassDecl(org.abs_models.frontend.ast.ClassDecl) Model(org.abs_models.frontend.ast.Model) Test(org.junit.Test)

Example 72 with ClassDecl

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));
}
Also used : ClassDecl(org.abs_models.frontend.ast.ClassDecl) Model(org.abs_models.frontend.ast.Model) Test(org.junit.Test)

Example 73 with ClassDecl

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));
}
Also used : ClassDecl(org.abs_models.frontend.ast.ClassDecl) Model(org.abs_models.frontend.ast.Model) Test(org.junit.Test)

Example 74 with ClassDecl

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());
}
Also used : ClassDecl(org.abs_models.frontend.ast.ClassDecl) Model(org.abs_models.frontend.ast.Model) Test(org.junit.Test)

Example 75 with ClassDecl

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());
}
Also used : ClassDecl(org.abs_models.frontend.ast.ClassDecl) Model(org.abs_models.frontend.ast.Model) Test(org.junit.Test)

Aggregations

ClassDecl (org.abs_models.frontend.ast.ClassDecl)79 Model (org.abs_models.frontend.ast.Model)72 Test (org.junit.Test)72 DeltaDecl (org.abs_models.frontend.ast.DeltaDecl)24 FrontendTest (org.abs_models.frontend.FrontendTest)15 ModifyClassModifier (org.abs_models.frontend.ast.ModifyClassModifier)12 SkipStmt (org.abs_models.frontend.ast.SkipStmt)11 ReturnStmt (org.abs_models.frontend.ast.ReturnStmt)10 KindedName (org.abs_models.frontend.typechecker.KindedName)10 DeltaTraitModifier (org.abs_models.frontend.ast.DeltaTraitModifier)7 ModifyMethodModifier (org.abs_models.frontend.ast.ModifyMethodModifier)7 TraitExpr (org.abs_models.frontend.ast.TraitExpr)7 MethodImpl (org.abs_models.frontend.ast.MethodImpl)6 AddMethodModifier (org.abs_models.frontend.ast.AddMethodModifier)5 MethodSig (org.abs_models.frontend.ast.MethodSig)5 ModuleDecl (org.abs_models.frontend.ast.ModuleDecl)5 TraitSetExpr (org.abs_models.frontend.ast.TraitSetExpr)5 HashSet (java.util.HashSet)4 List (org.abs_models.frontend.ast.List)4 ABSTest (org.abs_models.ABSTest)3