Search in sources :

Example 56 with Model

use of abs.frontend.ast.Model in project abstools by abstools.

the class DeltaSamplesTest method test_P2P_P4.

/*   @Test
    public void test_P2P_P3() throws Exception {
        Model m = assertTypeCheckFileOk("tests/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("tests/abssamples/deltas/PeerToPeer.abs", true);
    m.setNullPrintStream();
    m.flattenForProduct("P4");
    m.flushCache();
    SemanticConditionList res = m.typeCheck();
    if (res.containsErrors())
        fail(res.getFirstError().getMessage());
}
Also used : SemanticConditionList(abs.frontend.analyser.SemanticConditionList) Model(abs.frontend.ast.Model) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Example 57 with Model

use of abs.frontend.ast.Model in project abstools by abstools.

the class DeltaSamplesTest method test_ticket324_A.

@Test
@Ignore("https://github.com/abstools/abstools/issues/193")
public void test_ticket324_A() throws Exception {
    Model m = assertParseFileOk("tests/abssamples/deltas/bug324.abs", true);
    m.flattenForProduct("A");
    m.flushCache();
    assertFalse(m.hasTypeErrors());
}
Also used : Model(abs.frontend.ast.Model) Ignore(org.junit.Ignore) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Example 58 with Model

use of abs.frontend.ast.Model in project abstools by abstools.

the class DeltaTrieTest method trieStructure1.

@Test
public void trieStructure1() {
    Model model = assertParseOk("module Test;" + "delta D1;" + "delta D2;" + "productline PL;" + "features A,B;" + "delta D1 after D2 when A;" + "delta D2 when B;" + "root FM {" + " group [0..*] { A, B }" + "}");
    ProductLine pl = model.getProductLine();
    DeltaTrie pfgt = ProductLineAnalysisHelper.buildPFGT(pl, new SemanticConditionList());
    // System.out.println(pfgt.toString());
    assertTrue(pfgt.getRoot().isValidProduct());
    assertEquals(2, pfgt.getRoot().getChildren().size());
    assertTrue(pfgt.getRoot().getChildren().get("D1").isValidProduct());
    assertTrue(pfgt.getRoot().getChildren().get("D2").isValidProduct());
    assertEquals(0, pfgt.getRoot().getChildren().get("D1").getChildren().size());
    assertEquals(1, pfgt.getRoot().getChildren().get("D2").getChildren().size());
    assertTrue(pfgt.getRoot().getChildren().get("D2").getChildren().get("D1").isValidProduct());
}
Also used : SemanticConditionList(abs.frontend.analyser.SemanticConditionList) Model(abs.frontend.ast.Model) ProductLine(abs.frontend.ast.ProductLine) Test(org.junit.Test)

Example 59 with Model

use of abs.frontend.ast.Model in project abstools by abstools.

the class DeltaTrieTest method trieStructure2.

@Test
public void trieStructure2() {
    Model model = assertParseOk("module Test;" + "delta D1;" + "delta D2;" + "delta D3;" + "productline PL;" + "features A,B,C;" + "delta D1 when A;" + "delta D2 after D1 when B;" + "delta D3 after D2 when C;" + "root FM {" + " group [0..*] { A, B, C }" + "}");
    ProductLine pl = model.getProductLine();
    DeltaTrie pfgt = ProductLineAnalysisHelper.buildPFGT(pl, new SemanticConditionList());
    assertTrue(pfgt.getRoot().isValidProduct());
    assertEquals(3, pfgt.getRoot().getChildren().size());
    assertTrue(pfgt.getRoot().getChildren().get("D1").isValidProduct());
    assertTrue(pfgt.getRoot().getChildren().get("D2").isValidProduct());
    assertTrue(pfgt.getRoot().getChildren().get("D3").isValidProduct());
    assertEquals(2, pfgt.getRoot().getChildren().get("D1").getChildren().size());
    assertEquals(1, pfgt.getRoot().getChildren().get("D2").getChildren().size());
    assertEquals(0, pfgt.getRoot().getChildren().get("D3").getChildren().size());
    assertTrue(pfgt.getRoot().getChildren().get("D1").getChildren().get("D2").isValidProduct());
    assertTrue(pfgt.getRoot().getChildren().get("D1").getChildren().get("D3").isValidProduct());
    assertTrue(pfgt.getRoot().getChildren().get("D2").getChildren().get("D3").isValidProduct());
}
Also used : SemanticConditionList(abs.frontend.analyser.SemanticConditionList) Model(abs.frontend.ast.Model) ProductLine(abs.frontend.ast.ProductLine) Test(org.junit.Test)

Example 60 with Model

use of abs.frontend.ast.Model in project abstools by abstools.

the class OriginalCallTest method originalCall3.

@Test
public void originalCall3() throws DeltaModellingException {
    Model model = assertParseOk("module M;" + "interface I {}" + "class C implements I { Int one() { return 1; } }" + "delta D; uses M;" + "modifies class C { modifies Int one() { Int x = original(); return x + 1; } }");
    ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
    assertEquals(1, cls.getMethods().getNumChild());
    DeltaDecl delta1 = findDelta(model, "D");
    // Model.resolveOriginalCalls(new ArrayList<DeltaDecl>(Arrays.asList(delta1)));
    model.applyDeltas(new ArrayList<>(Arrays.asList(delta1)));
    assertEquals(2, cls.getMethods().getNumChild());
    assertTrue(cls.getMethod(0).getMethodSig().getName().equals("one"));
    // make sure method has the right body
    assertTrue(cls.getMethod(0).getBlock().getStmt(1) instanceof ReturnStmt);
    assertTrue(cls.getMethod(1).getMethodSig().getName().equals("one$ORIGIN_core"));
    // make sure method has the right body
    assertTrue(cls.getMethod(1).getBlock().getStmt(0) instanceof ReturnStmt);
}
Also used : ClassDecl(abs.frontend.ast.ClassDecl) Model(abs.frontend.ast.Model) DeltaDecl(abs.frontend.ast.DeltaDecl) ReturnStmt(abs.frontend.ast.ReturnStmt) Test(org.junit.Test)

Aggregations

Model (abs.frontend.ast.Model)224 Test (org.junit.Test)170 FrontendTest (abs.frontend.FrontendTest)93 ClassDecl (abs.frontend.ast.ClassDecl)57 DeltaDecl (abs.frontend.ast.DeltaDecl)30 SemanticConditionList (abs.frontend.analyser.SemanticConditionList)24 FunctionDecl (abs.frontend.ast.FunctionDecl)15 PrintStream (java.io.PrintStream)14 ModifyClassModifier (abs.frontend.ast.ModifyClassModifier)12 SkipStmt (abs.frontend.ast.SkipStmt)11 AbsNature (org.absmodels.abs.plugin.builder.AbsNature)11 ExpFunctionDef (abs.frontend.ast.ExpFunctionDef)9 ModuleDecl (abs.frontend.ast.ModuleDecl)9 CompilationUnit (abs.frontend.ast.CompilationUnit)7 DeltaTraitModifier (abs.frontend.ast.DeltaTraitModifier)7 ModifyMethodModifier (abs.frontend.ast.ModifyMethodModifier)7 PartialFunctionDecl (abs.frontend.ast.PartialFunctionDecl)7 PureExp (abs.frontend.ast.PureExp)7 TraitExpr (abs.frontend.ast.TraitExpr)7 WrongProgramArgumentException (abs.common.WrongProgramArgumentException)6