Search in sources :

Example 16 with Exp

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

the class FreeVarTest method letExp.

@Test
public void letExp() {
    Exp e = getSecondExp("{ Bool b = True; Bool c = let (Bool d) = True in b; }");
    assertEquals(e.getFreeVars(), "b");
}
Also used : Exp(abs.frontend.ast.Exp) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Example 17 with Exp

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

the class FreeVarTest method constructorApp.

@Test
public void constructorApp() {
    Exp e = getSecondExp("data D = C(Bool);{ Bool b; D d = C(b); }");
    assertEquals(e.getFreeVars(), "b");
}
Also used : Exp(abs.frontend.ast.Exp) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Example 18 with Exp

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

the class FreeVarTest method fieldUse.

@Test
public void fieldUse() {
    ClassDecl clazz = getFirstClassDecl(assertParseOkStdLib("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(abs.frontend.ast.ClassDecl) MethodImpl(abs.frontend.ast.MethodImpl) Exp(abs.frontend.ast.Exp) ReturnStmt(abs.frontend.ast.ReturnStmt) Stmt(abs.frontend.ast.Stmt) ReturnStmt(abs.frontend.ast.ReturnStmt) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Example 19 with Exp

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

the class FreeVarTest method parFnAppAnonymousFunction.

@Test
public void parFnAppAnonymousFunction() {
    Exp e = getSecondExp("def Bool f(g)() = g(); { Bool b = True; Bool b2 = f(() => b)(); }");
    assertEquals(e.getFreeVars(), "b");
}
Also used : Exp(abs.frontend.ast.Exp) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Example 20 with Exp

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

the class FreeVarTest method callExp.

@Test
public void callExp() {
    Exp e = getExp("interface I { Unit m(Bool b); } { Bool b = True; I i; Bool c = i.m(b); }", 2);
    assertEquals(e.getFreeVars(), "i", "b");
}
Also used : Exp(abs.frontend.ast.Exp) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Aggregations

Exp (abs.frontend.ast.Exp)24 FrontendTest (abs.frontend.FrontendTest)22 Test (org.junit.Test)22 PureExp (abs.frontend.ast.PureExp)2 ABSData (apet.testCases.ABSData)2 PreviousCall (apet.testCases.PreviousCall)2 Block (abs.frontend.ast.Block)1 ClassDecl (abs.frontend.ast.ClassDecl)1 DataTypeUse (abs.frontend.ast.DataTypeUse)1 EqExp (abs.frontend.ast.EqExp)1 InterfaceTypeUse (abs.frontend.ast.InterfaceTypeUse)1 MethodImpl (abs.frontend.ast.MethodImpl)1 NullExp (abs.frontend.ast.NullExp)1 ReturnStmt (abs.frontend.ast.ReturnStmt)1 Stmt (abs.frontend.ast.Stmt)1 VarUse (abs.frontend.ast.VarUse)1 ABSObject (apet.testCases.ABSObject)1 ABSRef (apet.testCases.ABSRef)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1