Search in sources :

Example 46 with Model

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

the class TypingTest method testContextDecl.

@Test
public void testContextDecl() {
    Model m = assertParseOk("class C implements I { I m() { return this; } } interface I { }");
    ClassDecl d = (ClassDecl) m.getDecls().iterator().next();
    ReturnStmt s = (ReturnStmt) d.getMethod(0).getBlock().getStmt(0);
    assertEquals(d, s.getRetExp().getContextDecl());
}
Also used : ClassDecl(abs.frontend.ast.ClassDecl) Model(abs.frontend.ast.Model) ReturnStmt(abs.frontend.ast.ReturnStmt) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Example 47 with Model

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

the class TypingTest method functionTypeArgs2.

@Test
public void functionTypeArgs2() {
    Model m = assertParseOkStdLib(" def Maybe<A> f<A>(Maybe<A> o) = o ;");
    ParametricFunctionDecl d = getLastParametricFunctionDecl(m);
    assertEquals(d.getTypeUse().getType(), ((ExpFunctionDef) d.getFunctionDef()).getRhs().getType());
}
Also used : ParametricFunctionDecl(abs.frontend.ast.ParametricFunctionDecl) Model(abs.frontend.ast.Model) ExpFunctionDef(abs.frontend.ast.ExpFunctionDef) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Example 48 with Model

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

the class TypingTest method testCase2.

@Test
public void testCase2() {
    Model m = assertParseOkStdLib("def Bool f(Bool x) = case x { True => x; False => x; };");
    assertEquals(m.getBoolType(), getFirstFunctionExpr(m).getType());
}
Also used : Model(abs.frontend.ast.Model) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Example 49 with Model

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

the class TypingTest method testAsyncCall.

@Test
public void testAsyncCall() {
    Model m = assertParseOkStdLib(" interface I { Bool m(); } { I i; i!m(); }");
    assertEquals(m.getFutType(m.getBoolType()), getSecondExp(m).getType());
}
Also used : Model(abs.frontend.ast.Model) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Example 50 with Model

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

the class TypingTest method testDataTypeBoolLit.

@Test
public void testDataTypeBoolLit() {
    Model m = assertParseOkStdLib("{ Bool i = True; }");
    assertEquals(m.getBoolType(), getTypeOfFirstAssignment(m));
}
Also used : Model(abs.frontend.ast.Model) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Aggregations

Model (abs.frontend.ast.Model)224 Test (org.junit.Test)170 FrontendTest (abs.frontend.FrontendTest)93 ClassDecl (abs.frontend.ast.ClassDecl)57 DeltaDecl (abs.frontend.ast.DeltaDecl)30 SemanticConditionList (abs.frontend.analyser.SemanticConditionList)24 FunctionDecl (abs.frontend.ast.FunctionDecl)15 PrintStream (java.io.PrintStream)14 ModifyClassModifier (abs.frontend.ast.ModifyClassModifier)12 SkipStmt (abs.frontend.ast.SkipStmt)11 AbsNature (org.absmodels.abs.plugin.builder.AbsNature)11 ExpFunctionDef (abs.frontend.ast.ExpFunctionDef)9 ModuleDecl (abs.frontend.ast.ModuleDecl)9 CompilationUnit (abs.frontend.ast.CompilationUnit)7 DeltaTraitModifier (abs.frontend.ast.DeltaTraitModifier)7 ModifyMethodModifier (abs.frontend.ast.ModifyMethodModifier)7 PartialFunctionDecl (abs.frontend.ast.PartialFunctionDecl)7 PureExp (abs.frontend.ast.PureExp)7 TraitExpr (abs.frontend.ast.TraitExpr)7 WrongProgramArgumentException (abs.common.WrongProgramArgumentException)6