Search in sources :

Example 6 with Feature

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

the class ProductDeclarationTest method complexExpression.

@Test
public void complexExpression() 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(2, impl.getNumFeature());
    Set<String> expected = new HashSet<>(Arrays.asList("F3", "F5"));
    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 7 with Feature

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

the class ProductDeclarationTest method unorderedProduct.

@Test
public void unorderedProduct() throws WrongProgramArgumentException {
    Model model = assertParse("product P2 = P1;" + "product P3 = P2;" + "product P1 = {F1, F2, F3};");
    model.evaluateAllProductDeclarations();
    ProductDecl p = model.findProduct("P3");
    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);
}
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 8 with Feature

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

the class ProductDeclarationTest method productFeatureSet.

@Test
public void productFeatureSet() 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);
}
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 9 with Feature

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

the class ProductDeclarationTest method productName.

@Test
public void productName() throws WrongProgramArgumentException {
    Model model = assertParse("product P1 = {F1, F2, F3};" + "product P2 = P1;");
    model.evaluateAllProductDeclarations();
    ProductDecl p = model.findProduct("P2");
    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);
}
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 10 with Feature

use of org.abs_models.frontend.ast.Feature 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)

Aggregations

Feature (org.abs_models.frontend.ast.Feature)11 HashSet (java.util.HashSet)10 Model (org.abs_models.frontend.ast.Model)10 Product (org.abs_models.frontend.ast.Product)10 ProductDecl (org.abs_models.frontend.ast.ProductDecl)10 Test (org.junit.Test)9 Constraint (choco.kernel.model.constraints.Constraint)1 ArrayList (java.util.ArrayList)1 WrongProgramArgumentException (org.abs_models.common.WrongProgramArgumentException)1 SemanticConditionList (org.abs_models.frontend.analyser.SemanticConditionList)1 AttrAssignment (org.abs_models.frontend.ast.AttrAssignment)1 DataConstructor (org.abs_models.frontend.ast.DataConstructor)1 DataConstructorExp (org.abs_models.frontend.ast.DataConstructorExp)1 DataTypeDecl (org.abs_models.frontend.ast.DataTypeDecl)1 Decl (org.abs_models.frontend.ast.Decl)1 ExpFunctionDef (org.abs_models.frontend.ast.ExpFunctionDef)1 FunctionDecl (org.abs_models.frontend.ast.FunctionDecl)1 IntVal (org.abs_models.frontend.ast.IntVal)1 List (org.abs_models.frontend.ast.List)1 ModuleDecl (org.abs_models.frontend.ast.ModuleDecl)1