Search in sources :

Example 1 with ProductLine

use of abs.frontend.ast.ProductLine in project abstools by abstools.

the class DeltaTrieTest method trieStructure1.

@Test
public void trieStructure1() {
    Model model = assertParseOk("module Test;" + "delta D1;" + "delta D2;" + "productline PL;" + "features A,B;" + "delta D1 after D2 when A;" + "delta D2 when B;" + "root FM {" + " group [0..*] { A, B }" + "}");
    ProductLine pl = model.getProductLine();
    DeltaTrie pfgt = ProductLineAnalysisHelper.buildPFGT(pl, new SemanticConditionList());
    // System.out.println(pfgt.toString());
    assertTrue(pfgt.getRoot().isValidProduct());
    assertEquals(2, pfgt.getRoot().getChildren().size());
    assertTrue(pfgt.getRoot().getChildren().get("D1").isValidProduct());
    assertTrue(pfgt.getRoot().getChildren().get("D2").isValidProduct());
    assertEquals(0, pfgt.getRoot().getChildren().get("D1").getChildren().size());
    assertEquals(1, pfgt.getRoot().getChildren().get("D2").getChildren().size());
    assertTrue(pfgt.getRoot().getChildren().get("D2").getChildren().get("D1").isValidProduct());
}
Also used : SemanticConditionList(abs.frontend.analyser.SemanticConditionList) Model(abs.frontend.ast.Model) ProductLine(abs.frontend.ast.ProductLine) Test(org.junit.Test)

Example 2 with ProductLine

use of abs.frontend.ast.ProductLine in project abstools by abstools.

the class DeltaTrieTest method trieStructure2.

@Test
public void trieStructure2() {
    Model model = assertParseOk("module Test;" + "delta D1;" + "delta D2;" + "delta D3;" + "productline PL;" + "features A,B,C;" + "delta D1 when A;" + "delta D2 after D1 when B;" + "delta D3 after D2 when C;" + "root FM {" + " group [0..*] { A, B, C }" + "}");
    ProductLine pl = model.getProductLine();
    DeltaTrie pfgt = ProductLineAnalysisHelper.buildPFGT(pl, new SemanticConditionList());
    assertTrue(pfgt.getRoot().isValidProduct());
    assertEquals(3, pfgt.getRoot().getChildren().size());
    assertTrue(pfgt.getRoot().getChildren().get("D1").isValidProduct());
    assertTrue(pfgt.getRoot().getChildren().get("D2").isValidProduct());
    assertTrue(pfgt.getRoot().getChildren().get("D3").isValidProduct());
    assertEquals(2, pfgt.getRoot().getChildren().get("D1").getChildren().size());
    assertEquals(1, pfgt.getRoot().getChildren().get("D2").getChildren().size());
    assertEquals(0, pfgt.getRoot().getChildren().get("D3").getChildren().size());
    assertTrue(pfgt.getRoot().getChildren().get("D1").getChildren().get("D2").isValidProduct());
    assertTrue(pfgt.getRoot().getChildren().get("D1").getChildren().get("D3").isValidProduct());
    assertTrue(pfgt.getRoot().getChildren().get("D2").getChildren().get("D3").isValidProduct());
}
Also used : SemanticConditionList(abs.frontend.analyser.SemanticConditionList) Model(abs.frontend.ast.Model) ProductLine(abs.frontend.ast.ProductLine) Test(org.junit.Test)

Example 3 with ProductLine

use of abs.frontend.ast.ProductLine in project abstools by abstools.

the class DeltaOrderingTest method properSorting1.

@Test
public void properSorting1() throws DeltaModellingException, WrongProgramArgumentException {
    Model model = assertParseOk("module Test;" + "delta D1;" + "delta D2;" + "productline PL;" + "features A,B;" + "delta D1 when A;" + "delta D2 after D1 when B;" + "product P1(A);" + "product P2(A, B);");
    model.evaluateAllProductDeclarations();
    ProductDecl prod = model.findProduct("P1");
    ProductLine pl = model.getProductLine();
    Set<String> deltaids = pl.findApplicableDeltas(prod.getProduct());
    List<String> sorted_deltaids = pl.sortDeltas(deltaids);
    assertArrayEquals(new String[] { "D1" }, sorted_deltaids.toArray());
    prod = model.findProduct("P2");
    deltaids = pl.findApplicableDeltas(prod.getProduct());
    sorted_deltaids = pl.sortDeltas(deltaids);
    assertArrayEquals(new String[] { "D1", "D2" }, sorted_deltaids.toArray());
    assertFalse(model.typeCheck().containsErrors());
}
Also used : ProductDecl(abs.frontend.ast.ProductDecl) Model(abs.frontend.ast.Model) ProductLine(abs.frontend.ast.ProductLine) Test(org.junit.Test)

Example 4 with ProductLine

use of abs.frontend.ast.ProductLine 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
}
Also used : SemanticConditionList(abs.frontend.analyser.SemanticConditionList) Model(abs.frontend.ast.Model) ProductLine(abs.frontend.ast.ProductLine) Test(org.junit.Test)

Example 5 with ProductLine

use of abs.frontend.ast.ProductLine in project abstools by abstools.

the class DeltaOrderingTest method properSorting9.

@Test
public void properSorting9() throws DeltaModellingException, WrongProgramArgumentException {
    Model model = assertParseOk("module Test;" + "delta D1;" + "delta D2;" + "delta D3;" + "delta D4;" + "delta D5;" + "delta D6;" + "delta D7;" + "delta D8;" + "delta D9;" + "productline PL;" + "features A,B,C,D,E,F,G,H,I;" + "delta D1 after D2 when A;" + "delta D2 after D3 when B;" + "delta D3 after D4 when C;" + "delta D4 after D5 when D;" + "delta D5 after D6 when E;" + "delta D6 after D7 when F;" + "delta D7 after D8 when G;" + "delta D8 after D9 when H;" + "delta D9 when I;" + "product P1(A,B,C,D,E,F,G,H,I);" + "product P2(A,C,E,G,I);");
    model.evaluateAllProductDeclarations();
    ProductDecl prod = model.findProduct("P1");
    ProductLine pl = model.getProductLine();
    Set<String> deltaids = pl.findApplicableDeltas(prod.getProduct());
    List<String> sorted_deltaids = pl.sortDeltas(deltaids);
    assertArrayEquals(new String[] { "D9", "D8", "D7", "D6", "D5", "D4", "D3", "D2", "D1" }, sorted_deltaids.toArray());
    prod = model.findProduct("P2");
    deltaids = pl.findApplicableDeltas(prod.getProduct());
    sorted_deltaids = pl.sortDeltas(deltaids);
    assertArrayEquals(new String[] { "D9", "D7", "D5", "D3", "D1" }, sorted_deltaids.toArray());
    assertFalse(model.typeCheck().containsErrors());
}
Also used : ProductDecl(abs.frontend.ast.ProductDecl) Model(abs.frontend.ast.Model) ProductLine(abs.frontend.ast.ProductLine) Test(org.junit.Test)

Aggregations

ProductLine (abs.frontend.ast.ProductLine)6 Model (abs.frontend.ast.Model)5 Test (org.junit.Test)5 SemanticConditionList (abs.frontend.analyser.SemanticConditionList)3 ProductDecl (abs.frontend.ast.ProductDecl)3 AppCond (abs.frontend.ast.AppCond)1 AppCondFeature (abs.frontend.ast.AppCondFeature)1 DeltaClause (abs.frontend.ast.DeltaClause)1 DeltaID (abs.frontend.ast.DeltaID)1 Deltaspec (abs.frontend.ast.Deltaspec)1 Feature (abs.frontend.ast.Feature)1 ProductFeatureSet (abs.frontend.ast.ProductFeatureSet)1 DeltaWrapper (apet.absunit.DeltaForGetSetFieldsBuilder.DeltaWrapper)1 HashSet (java.util.HashSet)1