Search in sources :

Example 31 with ClassDecl

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());
}
Also used : ClassDecl(org.abs_models.frontend.ast.ClassDecl) Model(org.abs_models.frontend.ast.Model) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Example 32 with ClassDecl

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);
}
Also used : ClassDecl(org.abs_models.frontend.ast.ClassDecl) Model(org.abs_models.frontend.ast.Model) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Example 33 with ClassDecl

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");
}
Also used : ClassDecl(org.abs_models.frontend.ast.ClassDecl) MethodImpl(org.abs_models.frontend.ast.MethodImpl) Exp(org.abs_models.frontend.ast.Exp) ReturnStmt(org.abs_models.frontend.ast.ReturnStmt) Stmt(org.abs_models.frontend.ast.Stmt) ReturnStmt(org.abs_models.frontend.ast.ReturnStmt) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Example 34 with ClassDecl

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);
}
Also used : ClassDecl(org.abs_models.frontend.ast.ClassDecl) Model(org.abs_models.frontend.ast.Model) AwaitAsyncCall(org.abs_models.frontend.ast.AwaitAsyncCall) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Example 35 with ClassDecl

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));
}
Also used : ClassDecl(org.abs_models.frontend.ast.ClassDecl) Model(org.abs_models.frontend.ast.Model) ModuleDecl(org.abs_models.frontend.ast.ModuleDecl) ResolvedName(org.abs_models.frontend.typechecker.ResolvedName) KindedName(org.abs_models.frontend.typechecker.KindedName) DeltaDecl(org.abs_models.frontend.ast.DeltaDecl) Test(org.junit.Test)

Aggregations

ClassDecl (org.abs_models.frontend.ast.ClassDecl)79 Model (org.abs_models.frontend.ast.Model)72 Test (org.junit.Test)72 DeltaDecl (org.abs_models.frontend.ast.DeltaDecl)24 FrontendTest (org.abs_models.frontend.FrontendTest)15 ModifyClassModifier (org.abs_models.frontend.ast.ModifyClassModifier)12 SkipStmt (org.abs_models.frontend.ast.SkipStmt)11 ReturnStmt (org.abs_models.frontend.ast.ReturnStmt)10 KindedName (org.abs_models.frontend.typechecker.KindedName)10 DeltaTraitModifier (org.abs_models.frontend.ast.DeltaTraitModifier)7 ModifyMethodModifier (org.abs_models.frontend.ast.ModifyMethodModifier)7 TraitExpr (org.abs_models.frontend.ast.TraitExpr)7 MethodImpl (org.abs_models.frontend.ast.MethodImpl)6 AddMethodModifier (org.abs_models.frontend.ast.AddMethodModifier)5 MethodSig (org.abs_models.frontend.ast.MethodSig)5 ModuleDecl (org.abs_models.frontend.ast.ModuleDecl)5 TraitSetExpr (org.abs_models.frontend.ast.TraitSetExpr)5 HashSet (java.util.HashSet)4 List (org.abs_models.frontend.ast.List)4 ABSTest (org.abs_models.ABSTest)3