Search in sources :

Example 16 with DeltaDecl

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

the class OtherAnalysisTests method awaitRewriteDecl2.

@Test
public void awaitRewriteDecl2() throws Exception {
    String deltaDecl = "delta D; modifies class C { adds Unit m() { return await this!m();}}";
    Model m = assertParseOk(deltaDecl);
    DeltaDecl d = m.findDelta("D");
    AwaitAsyncCall a = (AwaitAsyncCall) down(d);
    // pity, would like this to work.
    assertNotNull(a);
}
Also used : Model(abs.frontend.ast.Model) AwaitAsyncCall(abs.frontend.ast.AwaitAsyncCall) DeltaDecl(abs.frontend.ast.DeltaDecl) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Example 17 with DeltaDecl

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

the class PrettyPrinterTests method prettyPrinterAddDataTypeModifierTest.

@Test
public void prettyPrinterAddDataTypeModifierTest() throws Exception {
    String deltaDecl = "delta Foo;adds data States=F|B|I|M;";
    DeltaDecl d = (DeltaDecl) new ABSParserWrapper(null, true, false).parse(new StringReader(deltaDecl)).getDeltaDecl(0);
    assertEquals("deltaFoo;addsdataStates=F|B|I|M;", replaceWhitespaceChars(prettyPrint(d)));
}
Also used : ABSParserWrapper(abs.frontend.antlr.parser.ABSParserWrapper) StringReader(java.io.StringReader) DeltaDecl(abs.frontend.ast.DeltaDecl) Test(org.junit.Test) ABSTest(abs.ABSTest)

Example 18 with DeltaDecl

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

the class DeltaAddFunctionalTest method addFun.

@Test
public void addFun() throws DeltaModellingException {
    Model model = assertParseOk("module M;" + "def Int i() = 1;" + "delta I; uses M;" + "adds def Int j<A>(A a) = 2;" + "adds def Int h() = 2;");
    Decl funI = findDecl(model, "M", "i");
    assertNotNull(funI);
    assertThat(funI, instanceOf(FunctionDecl.class));
    DeltaDecl delta = findDelta(model, "I");
    assertNotNull(delta);
    assertThat(delta, instanceOf(DeltaDecl.class));
    Decl funj = findDecl(model, "M", "j");
    assertNull(funj);
    Decl funh = findDecl(model, "M", "h");
    assertNull(funh);
    model.applyDelta(delta);
    funj = findDecl(model, "M", "j");
    assertNotNull(funj);
    assertThat(funj, instanceOf(FunctionDecl.class));
    funh = findDecl(model, "M", "h");
    assertNotNull(funh);
    assertThat(funh, instanceOf(FunctionDecl.class));
}
Also used : Model(abs.frontend.ast.Model) DataTypeDecl(abs.frontend.ast.DataTypeDecl) ParametricDataTypeDecl(abs.frontend.ast.ParametricDataTypeDecl) TypeSynDecl(abs.frontend.ast.TypeSynDecl) FunctionDecl(abs.frontend.ast.FunctionDecl) Decl(abs.frontend.ast.Decl) DeltaDecl(abs.frontend.ast.DeltaDecl) DeltaDecl(abs.frontend.ast.DeltaDecl) FunctionDecl(abs.frontend.ast.FunctionDecl) Test(org.junit.Test)

Example 19 with DeltaDecl

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

the class OtherAnalysisTests method awaitRewriteDecl1.

@Test
public void awaitRewriteDecl1() {
    Model m = assertParseOk("module A; class C { } delta D; modifies class C { adds Unit m() { return await this!m();}}", Config.WITH_STD_LIB);
    DeltaDecl c = m.getDeltaDecls().iterator().next();
    AwaitAsyncCall a = (AwaitAsyncCall) down(c);
    // pity, would like this to work.
    assertNotNull(a);
}
Also used : Model(abs.frontend.ast.Model) AwaitAsyncCall(abs.frontend.ast.AwaitAsyncCall) DeltaDecl(abs.frontend.ast.DeltaDecl) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Example 20 with DeltaDecl

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

the class SourceCodePositionTest method test.

@Test
public void test() throws IOException, InternalBackendException {
    File fcore = folder.newFile("core.abs");
    File fd1 = folder.newFile("delta1.abs");
    File fd2 = folder.newFile("delta2.abs");
    {
        FileWriter writer = new FileWriter(fcore);
        writer.write("module M;" + "class C0 { Unit m() {} }");
        writer.close();
    }
    {
        FileWriter writer = new FileWriter(fd1);
        writer.write("delta D1; uses M;" + "adds class C1 { Unit m() {} }" + "modifies class C0 { modifies Unit m() {} }");
        writer.close();
    }
    {
        FileWriter writer = new FileWriter(fd2);
        writer.write("delta D2; uses M;" + "modifies class C1 { modifies Unit m() { original(); } }");
        writer.close();
    }
    HashSet<String> fileNames = new HashSet<>();
    fileNames.add(fcore.getCanonicalPath());
    fileNames.add(fd1.getCanonicalPath());
    fileNames.add(fd2.getCanonicalPath());
    Model model = assertParseFilesOk(fileNames, true);
    DeltaDecl d1 = findDelta(model, "D1");
    DeltaDecl d2 = findDelta(model, "D2");
    model.applyDeltas(new ArrayList<>(Arrays.asList(d1, d2)));
    {
        ClassDecl cls = (ClassDecl) findDecl(model, "M", "C0");
        assertEquals(cls.getMethod(0).getFileName(), d1.getFileName());
    }
    {
        ClassDecl cls = (ClassDecl) findDecl(model, "M", "C1");
        assertEquals(cls.getFileName(), d1.getFileName());
        assertEquals(cls.getMethod(0).getFileName(), d2.getFileName());
    }
}
Also used : ClassDecl(abs.frontend.ast.ClassDecl) FileWriter(java.io.FileWriter) Model(abs.frontend.ast.Model) DeltaDecl(abs.frontend.ast.DeltaDecl) File(java.io.File) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

DeltaDecl (abs.frontend.ast.DeltaDecl)37 Test (org.junit.Test)32 Model (abs.frontend.ast.Model)30 ClassDecl (abs.frontend.ast.ClassDecl)22 ModifyClassModifier (abs.frontend.ast.ModifyClassModifier)15 ModifyMethodModifier (abs.frontend.ast.ModifyMethodModifier)8 DeltaTraitModifier (abs.frontend.ast.DeltaTraitModifier)7 TraitExpr (abs.frontend.ast.TraitExpr)7 AddMethodModifier (abs.frontend.ast.AddMethodModifier)6 DeltaAccess (abs.frontend.ast.DeltaAccess)6 TraitSetExpr (abs.frontend.ast.TraitSetExpr)5 Block (abs.frontend.ast.Block)4 CompilationUnit (abs.frontend.ast.CompilationUnit)4 MethodImpl (abs.frontend.ast.MethodImpl)4 MethodSig (abs.frontend.ast.MethodSig)4 FrontendTest (abs.frontend.FrontendTest)3 DataTypeDecl (abs.frontend.ast.DataTypeDecl)3 Decl (abs.frontend.ast.Decl)3 FunctionDecl (abs.frontend.ast.FunctionDecl)3 List (abs.frontend.ast.List)3