Search in sources :

Example 31 with SemanticConditionList

use of org.abs_models.frontend.analyser.SemanticConditionList in project abstools by abstools.

the class ParFnAppTest method tooManyArgsForFuncParam.

@Test
public void tooManyArgsForFuncParam() {
    Model m = parse("apply(tooFew)(0);", applyFunction(), "def Int tooFew() = 0;");
    m.expandPartialFunctions();
    SemanticConditionList conditions = m.typeCheck();
    assertTrue(conditions.containsErrors());
}
Also used : SemanticConditionList(org.abs_models.frontend.analyser.SemanticConditionList) Model(org.abs_models.frontend.ast.Model) Test(org.junit.Test)

Example 32 with SemanticConditionList

use of org.abs_models.frontend.analyser.SemanticConditionList in project abstools by abstools.

the class ProductLineTypeAnalysisTest method wellFormedProductLine2.

@Test
public void wellFormedProductLine2() {
    Model model = assertParse("module M;" + "delta D1;" + "delta D2;" + "productline PL;" + "features A;" + "delta D1 after D2;" + "delta D2;");
    ProductLine pl = model.getProductLine();
    SemanticConditionList errors = new SemanticConditionList();
    /*
         * All OK
         */
    assertTrue(ProductLineAnalysisHelper.wellFormedProductLine(pl, errors));
    assertEquals(0, errors.getErrorCount());
}
Also used : SemanticConditionList(org.abs_models.frontend.analyser.SemanticConditionList) Test(org.junit.Test)

Example 33 with SemanticConditionList

use of org.abs_models.frontend.analyser.SemanticConditionList in project abstools by abstools.

the class ProductLineTypeAnalysisTest method stronglyUnambiguousProductLine2.

@Test
public void stronglyUnambiguousProductLine2() {
    Model model = assertParse("module M;" + "delta D1; uses M; modifies class C { adds Unit foo() {} }" + "delta D2; uses M; modifies class C { adds Unit bar() {} }" + "productline PL;" + "features A;" + "delta D1;" + "delta D2;");
    ProductLine pl = model.getProductLine();
    SemanticConditionList errors = new SemanticConditionList();
    /*
         * Both deltas are in same partition (no order specified)
         * They modify class C in different ways, by adding different methods
         */
    assertTrue(ProductLineAnalysisHelper.isStronglyUnambiguous(pl, errors));
    assertEquals(0, errors.getErrorCount());
}
Also used : SemanticConditionList(org.abs_models.frontend.analyser.SemanticConditionList) Test(org.junit.Test)

Example 34 with SemanticConditionList

use of org.abs_models.frontend.analyser.SemanticConditionList in project abstools by abstools.

the class ProductLineTypeAnalysisTest method stronglyUnambiguousProductLine3.

@Test
public void stronglyUnambiguousProductLine3() {
    Model model = assertParse("module M;" + "productline PL;" + "features A;");
    ProductLine pl = model.getProductLine();
    SemanticConditionList errors = new SemanticConditionList();
    /*
         * No deltas, no worries
         */
    assertTrue(ProductLineAnalysisHelper.isStronglyUnambiguous(pl, errors));
    assertEquals(0, errors.getErrorCount());
    List<Set<String>> partition = pl.getDeltaPartition();
    assertEquals(partition.size(), 0);
}
Also used : Set(java.util.Set) SemanticConditionList(org.abs_models.frontend.analyser.SemanticConditionList) Test(org.junit.Test)

Example 35 with SemanticConditionList

use of org.abs_models.frontend.analyser.SemanticConditionList in project abstools by abstools.

the class ProductLineTypeAnalysisTest method stronglyUnambiguousProductLine4.

@Test
public void stronglyUnambiguousProductLine4() {
    Model model = assertParse("module M;" + "delta D1; uses M; modifies class C { adds Unit foo() {} }" + "delta D2; uses M; modifies class C { adds Unit foo() {} }" + "productline PL;" + "features A;" + "delta D1;" + "delta D2;");
    ProductLine pl = model.getProductLine();
    SemanticConditionList errors = new SemanticConditionList();
    /* Both deltas are in same partition (no order specified)
         * Both deltas modify the same method C.foo
         */
    assertFalse(ProductLineAnalysisHelper.isStronglyUnambiguous(pl, errors));
    assertEquals(1, errors.getErrorCount());
}
Also used : SemanticConditionList(org.abs_models.frontend.analyser.SemanticConditionList) Test(org.junit.Test)

Aggregations

SemanticConditionList (org.abs_models.frontend.analyser.SemanticConditionList)42 Model (org.abs_models.frontend.ast.Model)27 Test (org.junit.Test)27 ProductLine (org.abs_models.frontend.ast.ProductLine)7 SemanticCondition (org.abs_models.frontend.analyser.SemanticCondition)6 FrontendTest (org.abs_models.frontend.FrontendTest)5 ProductDecl (org.abs_models.frontend.ast.ProductDecl)3 ABSTest (org.abs_models.ABSTest)2 TypeError (org.abs_models.frontend.analyser.TypeError)2 Constraint (choco.kernel.model.constraints.Constraint)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 IOException (java.io.IOException)1 PrintStream (java.io.PrintStream)1 PrintWriter (java.io.PrintWriter)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 InternalBackendException (org.abs_models.backend.common.InternalBackendException)1 DefaultABSFormatter (org.abs_models.backend.prettyprint.DefaultABSFormatter)1