Search in sources :

Example 1 with SemanticConditionList

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

the class ProductLineTypeAnalysisTest method stronglyUnambiguousProductLine1.

@Test
public void stronglyUnambiguousProductLine1() {
    Model model = assertParse("module M;" + "delta D1; uses M; modifies class C { adds Unit foo() {} }" + "delta D2; modifies class M.C { adds Unit foo() {} }" + "productline PL;" + "features A;" + "delta D1;" + "delta D2 after D1;");
    ProductLine pl = model.getProductLine();
    SemanticConditionList errors = new SemanticConditionList();
    assertTrue(ProductLineAnalysisHelper.isStronglyUnambiguous(pl, errors));
    assertEquals(0, errors.getErrorCount());
}
Also used : SemanticConditionList(org.abs_models.frontend.analyser.SemanticConditionList) Test(org.junit.Test)

Example 2 with SemanticConditionList

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

the class ProductLineTypeAnalysisTest method stronglyUnambiguousProductLine5.

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

Example 3 with SemanticConditionList

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

the class ProductLineTypeAnalysisTest method stronglyUnambiguousProductLinePerformance.

@Test
public void stronglyUnambiguousProductLinePerformance() {
    Model model = assertParse("module M; class C {}");
    CompilationUnit cu = new CompilationUnit();
    model.addCompilationUnit(cu);
    ProductLine pl = new ProductLine();
    pl.setName("PL");
    cu.setProductLine(pl);
    int n = 2000;
    for (int i = 0; i < n; i++) {
        String id = Integer.toHexString(UUID.randomUUID().hashCode());
        ModifyClassModifier cmod = new ModifyClassModifier();
        cmod.setName("C");
        MethodSig msig = new MethodSig();
        msig.setName("m" + id);
        MethodImpl mimpl = new MethodImpl();
        mimpl.setMethodSig(msig);
        org.abs_models.frontend.ast.List<MethodImpl> list = new org.abs_models.frontend.ast.List<>();
        list.add(mimpl);
        DeltaTraitModifier dmod = new DeltaTraitModifier(new ModifyMethodModifier(new TraitSetExpr(list)));
        cu.addDeltaDecl(new DeltaDecl("D" + id, new org.abs_models.frontend.ast.List<>(), new org.abs_models.frontend.ast.Opt<>(), new org.abs_models.frontend.ast.List<>(cmod)));
        DeltaClause dc = new DeltaClause();
        Deltaspec dspec = new Deltaspec();
        dspec.setDeltaID("D" + id);
        dc.setDeltaspec(dspec);
        pl.addDeltaClause(dc);
    }
    pl = model.getProductLine();
    SemanticConditionList errors = new SemanticConditionList();
    long startTime = System.currentTimeMillis();
    assertTrue(ProductLineAnalysisHelper.isStronglyUnambiguous(pl, errors));
    long stopTime = System.currentTimeMillis();
// System.out.println(n + " deltas. time (ms): " + (stopTime - startTime));
}
Also used : org.abs_models.frontend.ast(org.abs_models.frontend.ast) SemanticConditionList(org.abs_models.frontend.analyser.SemanticConditionList) List(java.util.List) SemanticConditionList(org.abs_models.frontend.analyser.SemanticConditionList) Test(org.junit.Test)

Example 4 with SemanticConditionList

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

the class ProductDeclarationTest method invalidProduct.

@Test
public void invalidProduct() throws WrongProgramArgumentException {
    Model model = assertParse("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 : 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)

Example 5 with SemanticConditionList

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

the class ProgramAbstractionTest method removeClass.

@Test
public void removeClass() {
    Model model = assertParse("module M;" + "class C(Rat myParam) { Int myField = 99; Int myMethod(String a, Bool b) { return 88; } }" + "delta D;" + "uses M;" + "removes class C;" + "productline PL;" + "features F;" + "delta D when F;" + "root FM { group allof { opt F } }");
    SemanticConditionList errors = new SemanticConditionList();
    ProductLine pl = model.getProductLine();
    DeltaTrie trie = ProductLineAnalysisHelper.buildPFGT(pl, errors);
    ProgramAbstraction pa = trie.getRoot().getChildren().get("D").getProgramAbstraction();
    System.out.println("******\n" + pa);
    assertFalse(pa.getClasses().containsKey("M.C"));
}
Also used : SemanticConditionList(org.abs_models.frontend.analyser.SemanticConditionList) Model(org.abs_models.frontend.ast.Model) ProductLine(org.abs_models.frontend.ast.ProductLine) 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