use of org.abs_models.frontend.ast.ClassDecl in project abstools by abstools.
the class LocationTypeTests method multipleError.
@Test(expected = LocationTypeCheckerException.class)
public void multipleError() {
Model m = assertParse("interface I { } class C { [Far] [Near] I i; }");
ClassDecl decl = getFirstClassDecl(m);
LocationTypeExtension.getLocationTypeFromAnnotations(decl.getField(0).getType());
}
use of org.abs_models.frontend.ast.ClassDecl in project abstools by abstools.
the class LocationTypeTests method fieldDecl.
@Test
public void fieldDecl() {
Model m = assertParse("interface I { } class C { [Far] I i; }");
ClassDecl decl = getFirstClassDecl(m);
LocationType ft = LocationTypeExtension.getLocationTypeFromAnnotations(decl.getField(0).getType());
assertEquals(LocationType.FAR, ft);
}
use of org.abs_models.frontend.ast.ClassDecl in project abstools by abstools.
the class FreeVarTest method fieldUse.
@Test
public void fieldUse() {
ClassDecl clazz = getFirstClassDecl(assertParse("class C {" + "Int i = 0;" + "Int m() {" + "return i + 1;" + "}" + "}"));
MethodImpl method = clazz.lookupMethod("m");
assertNotNull(method);
Stmt stmt = method.getBlock().getStmt(0);
assertTrue(stmt instanceof ReturnStmt);
ReturnStmt returnStmt = (ReturnStmt) stmt;
Exp exp = returnStmt.getRetExp();
assertEquals(exp.getFreeVars(), "i");
}
use of org.abs_models.frontend.ast.ClassDecl in project abstools by abstools.
the class OtherAnalysisTests method testContext1.
@Test
public void testContext1() {
Model m = assertParse("interface I { Unit m(); } class C implements I { Unit m() {Unit x = await this!m();}}", Config.TYPE_CHECK);
ClassDecl cd = (ClassDecl) m.lookupModule("UnitTest").getDecl(1);
int n = cd.findChildren(AwaitAsyncCall.class).size();
assertEquals("Rewrite failed", n, 0);
}
use of org.abs_models.frontend.ast.ClassDecl in project abstools by abstools.
the class AddImportsTest method addExport.
@Test
public void addExport() throws DeltaModellingException {
Model model = assertParse("module Exporter;" + "interface I {}" + "module M;" + "class C {}" + "delta D1; uses Exporter;" + "adds export I;" + "delta D2; uses M;" + "adds import Exporter.I;" + "modifies class C { adds Exporter.I field1; } ");
ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
DeltaDecl d1 = findDelta(model, "D1");
DeltaDecl d2 = findDelta(model, "D2");
model.applyDeltas(new ArrayList<>(Arrays.asList(d1, d2)));
ModuleDecl clsmodule = cls.getModuleDecl();
Map<KindedName, ResolvedName> clsVisibleSymbols = clsmodule.getVisibleNames();
KindedName symbol1 = new KindedName(KindedName.Kind.TYPE_DECL, "Exporter.I");
assertTrue(clsVisibleSymbols.containsKey(symbol1));
}
Aggregations