Search in sources :

Example 11 with Product

use of org.abs_models.frontend.ast.Product in project abstools by abstools.

the class ProductDeclarationTest method complexExpressionWithParenthesis.

@Test
public void complexExpressionWithParenthesis() throws WrongProgramArgumentException {
    Model model = assertParse("product P1 = {F1, F2, F3} && ({F3, F4} || {F5}) || {F6} - {F6};");
    model.evaluateAllProductDeclarations();
    ProductDecl p = model.findProduct("P1");
    Product impl = p.getProduct();
    assertEquals(1, impl.getNumFeature());
    Set<String> expected = new HashSet<>(Arrays.asList("F3"));
    Set<String> actual = new HashSet<>();
    for (Feature f : impl.getFeatures()) actual.add(f.getName());
    assertEquals(expected, actual);
}
Also used : ProductDecl(org.abs_models.frontend.ast.ProductDecl) Model(org.abs_models.frontend.ast.Model) Product(org.abs_models.frontend.ast.Product) Feature(org.abs_models.frontend.ast.Feature) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 12 with Product

use of org.abs_models.frontend.ast.Product in project abstools by abstools.

the class ProductDeclarationTest method productDifference.

@Test
public void productDifference() throws WrongProgramArgumentException {
    Model model = assertParse("product P1 = {F1, F2, F3, F4} - {F2, F3};");
    model.evaluateAllProductDeclarations();
    ProductDecl p = model.findProduct("P1");
    Product impl = p.getProduct();
    assertEquals(2, impl.getNumFeature());
    Set<String> expected = new HashSet<>(Arrays.asList("F1", "F4"));
    Set<String> actual = new HashSet<>();
    for (Feature f : impl.getFeatures()) actual.add(f.getName());
    assertEquals(expected, actual);
}
Also used : ProductDecl(org.abs_models.frontend.ast.ProductDecl) Model(org.abs_models.frontend.ast.Model) Product(org.abs_models.frontend.ast.Product) Feature(org.abs_models.frontend.ast.Feature) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Product (org.abs_models.frontend.ast.Product)12 Model (org.abs_models.frontend.ast.Model)11 HashSet (java.util.HashSet)10 Feature (org.abs_models.frontend.ast.Feature)10 ProductDecl (org.abs_models.frontend.ast.ProductDecl)9 Test (org.junit.Test)9 Constraint (choco.kernel.model.constraints.Constraint)1 AttrAssignment (org.abs_models.frontend.ast.AttrAssignment)1 IntVal (org.abs_models.frontend.ast.IntVal)1 ChocoSolver (org.abs_models.frontend.mtvl.ChocoSolver)1