use of org.abs_models.frontend.ast.Exp in project abstools by abstools.
the class VarResolutionTest method testLocalVar.
@Test
public void testLocalVar() {
Exp e = getSecondExp("interface I { } { I i = null; i = i; }");
VarUse u = (VarUse) e;
VarDecl decl = (VarDecl) u.getDecl();
assertEquals("i", decl.getName());
}
use of org.abs_models.frontend.ast.Exp 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.Exp in project abstools by abstools.
the class FreeVarTest method letExp3.
@Test
public void letExp3() {
Exp e = getSecondExp("{ Bool b = True; Bool c = let (Bool b) = b in b; }");
assertEquals(e.getFreeVars(), "b");
}
use of org.abs_models.frontend.ast.Exp in project abstools by abstools.
the class FreeVarTest method ifExpr.
@Test
public void ifExpr() {
Exp e = getExp("{ Int x = 3; Int y = 4; Int z = 5; Int a = when x == 3 then y else z; }", 3);
assertEquals(e.getFreeVars(), "x", "y", "z");
}
use of org.abs_models.frontend.ast.Exp in project abstools by abstools.
the class FreeVarTest method varUseExp.
@Test
public void varUseExp() {
Exp e = getSecondExp("{ Bool b = True; Bool c = b; }");
assertEquals(e.getFreeVars(), "b");
}
Aggregations