Search in sources :

Example 36 with SemanticConditionList

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

the class ProductLineTypeAnalysisTest method stronglyUnambiguousProductLine6.

@Test
public void stronglyUnambiguousProductLine6() {
    Model model = assertParse("module M;" + "delta D1; uses M; modifies class C { adds Unit foo() {} }" + "delta D2; uses M; removes class C;" + "delta D3; uses M; adds class C {}" + "productline PL;" + "features A;" + "delta D1;" + "delta D2;" + "delta D3;");
    ProductLine pl = model.getProductLine();
    SemanticConditionList errors = new SemanticConditionList();
    /* All 3 deltas are in same partition
         * D1, D2, D3 act on the same class C
         */
    assertFalse(ProductLineAnalysisHelper.isStronglyUnambiguous(pl, errors));
    assertEquals(2, errors.getErrorCount());
}
Also used : SemanticConditionList(org.abs_models.frontend.analyser.SemanticConditionList) Test(org.junit.Test)

Example 37 with SemanticConditionList

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

the class ProductLineTypeAnalysisTest method wellFormedProductLine1.

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

Example 38 with SemanticConditionList

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

the class DeltaSamplesTest method test_P2P_P4.

/*   @Test
    public void test_P2P_P3() throws Exception {
        Model m = assertTypeCheckFileOk("abssamples/deltas/PeerToPeer.abs", true);
        m.setNullPrintStream();
        thrown.expect(DeltaModellingWithNodeException.class);
        m.flattenForProduct("P3");
    }
*/
@Test
public void test_P2P_P4() throws Exception {
    Model m = assertParseFileOk("abssamples/deltas/PeerToPeer.abs");
    m.setNullPrintStream();
    m.flattenForProduct("P4");
    m.flushCache();
    SemanticConditionList res = m.typeCheck();
    if (res.containsErrors())
        fail(res.getFirstError().getMessage());
}
Also used : SemanticConditionList(org.abs_models.frontend.analyser.SemanticConditionList) Model(org.abs_models.frontend.ast.Model) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Example 39 with SemanticConditionList

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

the class DeltaSamplesTest method test_ticket329.

@Test
public void test_ticket329() throws Exception {
    Model m = assertParseFileOk("abssamples/deltas/bug329.abs");
    SemanticConditionList errs = m.typeCheck();
    /* We are expecting a missing delta in product M.PL: */
    assertThat(errs.getFirstError(), instanceOf(TypeError.class));
    TypeError te = (TypeError) errs.getFirstError();
    Assert.assertEquals(ErrorMessage.NAME_NOT_RESOLVABLE, te.msg);
}
Also used : SemanticConditionList(org.abs_models.frontend.analyser.SemanticConditionList) Model(org.abs_models.frontend.ast.Model) TypeError(org.abs_models.frontend.analyser.TypeError) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Example 40 with SemanticConditionList

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

the class ProductDeclarationTest method validProduct.

@Test
public void validProduct() throws WrongProgramArgumentException {
    Model model = assertParse("product P1 = {F1, F2, F3};" + "root FM {" + "group allof { F1, F2, F3 }" + "}");
    model.evaluateAllProductDeclarations();
    ProductDecl p = model.findProduct("P1");
    SemanticConditionList e = new SemanticConditionList();
    typeCheck(model, p, e);
    assertEquals(0, e.getErrorCount());
}
Also used : ProductDecl(org.abs_models.frontend.ast.ProductDecl) SemanticConditionList(org.abs_models.frontend.analyser.SemanticConditionList) Model(org.abs_models.frontend.ast.Model) 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