Search in sources :

Example 91 with Model

use of org.abs_models.frontend.ast.Model in project abstools by abstools.

the class TreeUtilsTest method closestParent.

@Test
public void closestParent() {
    Model model = assertParse("def Int test() = 1;");
    FunctionDecl functionDecl = getLastFunctionDecl(model);
    assertEquals("test", functionDecl.getName());
    PureExp exp = ((ExpFunctionDef) functionDecl.getFunctionDef()).getRhs();
    assertSame(functionDecl, exp.closestParent(Decl.class));
    assertSame(functionDecl, exp.closestParent(FunctionDecl.class));
}
Also used : Model(org.abs_models.frontend.ast.Model) FunctionDecl(org.abs_models.frontend.ast.FunctionDecl) Decl(org.abs_models.frontend.ast.Decl) PureExp(org.abs_models.frontend.ast.PureExp) FunctionDecl(org.abs_models.frontend.ast.FunctionDecl) ExpFunctionDef(org.abs_models.frontend.ast.ExpFunctionDef) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Example 92 with Model

use of org.abs_models.frontend.ast.Model in project abstools by abstools.

the class TreeUtilsTest method findChildrenIncludeOnlySelf.

@Test
public void findChildrenIncludeOnlySelf() {
    Model model = assertParse("def Int test(Int i) = test(1);");
    FunctionDecl functionDecl = getLastFunctionDecl(model);
    assertEquals("test", functionDecl.getName());
    ExpFunctionDef def = (ExpFunctionDef) functionDecl.getFunctionDef();
    PureExp exp = def.getRhs();
    Stream<PureExp> children = def.findChildren(cast(PureExp.class), n -> false);
    assertNotNull(children);
    List<PureExp> result = children.distinct().collect(Collectors.toList());
    assertEquals(1, result.size());
    assertTrue(result.contains(exp));
}
Also used : Model(org.abs_models.frontend.ast.Model) PureExp(org.abs_models.frontend.ast.PureExp) FunctionDecl(org.abs_models.frontend.ast.FunctionDecl) ExpFunctionDef(org.abs_models.frontend.ast.ExpFunctionDef) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Example 93 with Model

use of org.abs_models.frontend.ast.Model in project abstools by abstools.

the class AnnotationTests method testFieldDecl.

@Test
public void testFieldDecl() {
    Model m = assertParseOkAnn("class C { [Far] I i; }");
    ClassDecl decl = getFirstClassDecl(m);
    assertHasLocAnnotation(decl.getField(0).getType(), "Far");
}
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 94 with Model

use of org.abs_models.frontend.ast.Model in project abstools by abstools.

the class AnnotationTests method testMethodParam.

@Test
public void testMethodParam() {
    Model m = assertParseOkAnn("class C { Unit m([Far] I i) { } }");
    ClassDecl decl = getFirstClassDecl(m);
    assertHasLocAnnotation(decl.getMethod(0).getMethodSig().getParam(0).getType(), "Far");
}
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 95 with Model

use of org.abs_models.frontend.ast.Model in project abstools by abstools.

the class AnnotationTests method testVarDecl.

@Test
public void testVarDecl() {
    Model m = assertParseOkAnn("{ [Near] I i; }");
    VarDeclStmt v = ((VarDeclStmt) m.getMainBlock().getStmt(0));
    assertHasLocAnnotation(v.getVarDecl().getType(), "Near");
}
Also used : VarDeclStmt(org.abs_models.frontend.ast.VarDeclStmt) Model(org.abs_models.frontend.ast.Model) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Aggregations

Model (org.abs_models.frontend.ast.Model)268 Test (org.junit.Test)227 FrontendTest (org.abs_models.frontend.FrontendTest)101 ClassDecl (org.abs_models.frontend.ast.ClassDecl)72 DeltaDecl (org.abs_models.frontend.ast.DeltaDecl)34 SemanticConditionList (org.abs_models.frontend.analyser.SemanticConditionList)29 ABSTest (org.abs_models.ABSTest)22 ProductDecl (org.abs_models.frontend.ast.ProductDecl)17 FunctionDecl (org.abs_models.frontend.ast.FunctionDecl)15 HashSet (java.util.HashSet)13 ModifyClassModifier (org.abs_models.frontend.ast.ModifyClassModifier)13 PrintStream (java.io.PrintStream)12 Product (org.abs_models.frontend.ast.Product)11 SkipStmt (org.abs_models.frontend.ast.SkipStmt)11 VarUse (org.abs_models.frontend.ast.VarUse)11 Feature (org.abs_models.frontend.ast.Feature)10 File (java.io.File)9 ExpFunctionDef (org.abs_models.frontend.ast.ExpFunctionDef)9 ReturnStmt (org.abs_models.frontend.ast.ReturnStmt)9 KindedName (org.abs_models.frontend.typechecker.KindedName)9