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);
}
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)));
}
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));
}
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);
}
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());
}
}
Aggregations