use of org.abs_models.frontend.ast.ProductDecl in project abstools by abstools.
the class DeltaOrderingTest method properSorting9.
@Test
public void properSorting9() throws DeltaModellingException, WrongProgramArgumentException {
Model model = assertParse("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());
}
use of org.abs_models.frontend.ast.ProductDecl in project abstools by abstools.
the class ProductDeclarationTest method productUnion.
@Test
public void productUnion() throws WrongProgramArgumentException {
Model model = assertParse("product P1 = {F1, F2, F3} || {F4};");
model.evaluateAllProductDeclarations();
ProductDecl p = model.findProduct("P1");
Product impl = p.getProduct();
assertEquals(4, impl.getNumFeature());
Set<String> expected = new HashSet<>(Arrays.asList("F1", "F2", "F3", "F4"));
Set<String> actual = new HashSet<>();
for (Feature f : impl.getFeatures()) actual.add(f.getName());
assertEquals(expected, actual);
}
use of org.abs_models.frontend.ast.ProductDecl in project abstools by abstools.
the class ProductDeclarationTest method oldProductSyntax.
@Test
public void oldProductSyntax() throws WrongProgramArgumentException {
Model model = assertParse("product P1(F1, F2, F3);");
model.evaluateAllProductDeclarations();
ProductDecl p = model.findProduct("P1");
Product impl = p.getProduct();
assertEquals(3, impl.getNumFeature());
Set<String> expected = new HashSet<>(Arrays.asList("F1", "F2", "F3"));
Set<String> actual = new HashSet<>();
for (Feature f : impl.getFeatures()) actual.add(f.getName());
assertEquals(expected, actual);
}
use of org.abs_models.frontend.ast.ProductDecl in project abstools by abstools.
the class ProductDeclarationTest method productIntersect.
@Test
public void productIntersect() throws WrongProgramArgumentException {
Model model = assertParse("product P1 = {F1, F2, F3} && {F2, F3};");
model.evaluateAllProductDeclarations();
ProductDecl p = model.findProduct("P1");
Product impl = p.getProduct();
assertEquals(2, impl.getNumFeature());
Set<String> expected = new HashSet<>(Arrays.asList("F2", "F3"));
Set<String> actual = new HashSet<>();
for (Feature f : impl.getFeatures()) actual.add(f.getName());
assertEquals(expected, actual);
}
use of org.abs_models.frontend.ast.ProductDecl 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);
}
Aggregations