Search in sources :

Example 11 with SemanticConditionList

use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.

the class ProductDeclarationTest method undeclaredProduct.

@Test
public void undeclaredProduct() throws WrongProgramArgumentException {
    Model model = assertParseOk("product P1 = P2 && P3 || P4 || {F1, F2};");
    ProductDecl p = model.findProduct("P1");
    SemanticConditionList e = new SemanticConditionList();
    typeCheck(model, p, e);
    assertEquals(3, e.getErrorCount());
    assertEquals(ErrorMessage.UNDECLARED_PRODUCT, e.getFirstError().msg);
}
Also used : SemanticConditionList(abs.frontend.analyser.SemanticConditionList) Test(org.junit.Test)

Example 12 with SemanticConditionList

use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.

the class ProductDeclarationTest method invalidProduct.

@Test
public void invalidProduct() throws WrongProgramArgumentException {
    Model model = assertParseOk("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);
}
Also used : SemanticConditionList(abs.frontend.analyser.SemanticConditionList) Test(org.junit.Test)

Example 13 with SemanticConditionList

use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.

the class ProductLineTypeAnalysisTest method stronglyUnambiguousProductLine2.

@Test
public void stronglyUnambiguousProductLine2() {
    Model model = assertParseOk("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(abs.frontend.analyser.SemanticConditionList) Test(org.junit.Test)

Example 14 with SemanticConditionList

use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.

the class ProductLineTypeAnalysisTest method wellFormedProductLine2.

@Test
public void wellFormedProductLine2() {
    Model model = assertParseOk("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(abs.frontend.analyser.SemanticConditionList) Test(org.junit.Test)

Example 15 with SemanticConditionList

use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.

the class ProductLineTypeAnalysisTest method stronglyUnambiguousProductLine5.

@Test
public void stronglyUnambiguousProductLine5() {
    Model model = assertParseOk("module M;" + "delta D1; uses M; adds class C {}" + "delta D2; uses M; removes class C;" + "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 act on the same class C
         */
    assertFalse(ProductLineAnalysisHelper.isStronglyUnambiguous(pl, errors));
    assertEquals(1, errors.getErrorCount());
}
Also used : SemanticConditionList(abs.frontend.analyser.SemanticConditionList) Test(org.junit.Test)

Aggregations

SemanticConditionList (abs.frontend.analyser.SemanticConditionList)51 Test (org.junit.Test)30 Model (abs.frontend.ast.Model)24 FrontendTest (abs.frontend.FrontendTest)7 SemanticCondition (abs.frontend.analyser.SemanticCondition)7 LocationTypeInferrerExtension (abs.frontend.typechecker.locationtypes.infer.LocationTypeInferrerExtension)7 LocationType (abs.frontend.typechecker.locationtypes.LocationType)5 LocationTypeExtension (abs.frontend.typechecker.locationtypes.LocationTypeExtension)4 WrongProgramArgumentException (abs.common.WrongProgramArgumentException)3 ProductLine (abs.frontend.ast.ProductLine)3 TypeError (abs.frontend.analyser.TypeError)2 CompilationUnit (abs.frontend.ast.CompilationUnit)2 DeltaModellingException (abs.frontend.delta.DeltaModellingException)2 Main (abs.frontend.parser.Main)2 ParserError (abs.frontend.parser.ParserError)2 File (java.io.File)2 ABSTest (abs.ABSTest)1 InternalBackendException (abs.backend.common.InternalBackendException)1 DefaultABSFormatter (abs.backend.prettyprint.DefaultABSFormatter)1 SemanticError (abs.frontend.analyser.SemanticError)1