Search in sources :

Example 41 with Model

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

the class TypingTest method functionTypeArgs4.

@Test
public void functionTypeArgs4() {
    Model m = assertParseOkStdLib(" data Foo<A> = Bar(A,Bool); " + "def Bool f<A>(Foo<A> o) = case o { Bar(a,b) => b; } ;");
    ParametricFunctionDecl d = getLastParametricFunctionDecl(m);
    Type type = ((ExpFunctionDef) d.getFunctionDef()).getRhs().getType();
    assertEquals(m.getBoolType(), type);
}
Also used : ParametricFunctionDecl(abs.frontend.ast.ParametricFunctionDecl) Type(abs.frontend.typechecker.Type) DataTypeType(abs.frontend.typechecker.DataTypeType) UnionType(abs.frontend.typechecker.UnionType) Model(abs.frontend.ast.Model) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Example 42 with Model

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

the class TypingTest method testInterfaceType.

@Test
public void testInterfaceType() {
    Model m = assertParseOk("interface I { } class C {} { I i = new local C(); I i2 = i; }");
    assertEquals(m.lookupModule("UnitTest").getDecl(0).getType(), getTypeOfNthAssignment(m, 2));
}
Also used : Model(abs.frontend.ast.Model) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Example 43 with Model

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

the class TypingTest method testFnApp.

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

Example 44 with Model

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

the class TypingTest method testDataTypeStringLit.

@Test
public void testDataTypeStringLit() {
    Model m = assertParseOkStdLib("{ String i = \"5\"; }");
    assertEquals(m.getStringType(), getTypeOfFirstAssignment(m));
}
Also used : Model(abs.frontend.ast.Model) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Example 45 with Model

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

the class TypingTest method testDataTypeIntLit.

@Test
public void testDataTypeIntLit() {
    Model m = assertParseOkStdLib("{ Int i = 5; }");
    assertEquals(m.getIntType(), getTypeOfFirstAssignment(m));
}
Also used : Model(abs.frontend.ast.Model) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Aggregations

Model (abs.frontend.ast.Model)226 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