Search in sources :

Example 96 with Model

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

the class AnnotationTests method testClassParam.

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

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

the class NullCheckerTests method assertTypeErrors.

@Override
protected SemanticCondition assertTypeErrors(String absCode, Config... config) {
    Model m = assertParse(absCode, config);
    String msg = "";
    m.registerTypeSystemExtension(new NullCheckerExtension(m));
    SemanticConditionList l = m.typeCheck();
    if (l.containsErrors()) {
        msg = l.getFirstError().getMsgWithHint(absCode);
    } else if (l.containsWarnings() && isSet(EXPECT_WARNING, config)) {
        msg = l.getFirstWarning().getMsgWithHint(absCode);
    }
    assertEquals(msg, isSet(EXPECT_TYPE_ERROR, config), l.containsErrors());
    if (isSet(EXPECT_WARNING, config)) {
        assertEquals(msg, isSet(EXPECT_WARNING, config), l.containsWarnings());
    }
    return l.containsErrors() ? l.getFirstError() : null;
}
Also used : SemanticConditionList(org.abs_models.frontend.analyser.SemanticConditionList) Model(org.abs_models.frontend.ast.Model) NullCheckerExtension(org.abs_models.frontend.typechecker.nullable.NullCheckerExtension)

Example 98 with Model

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

the class TypingTest method testFieldUse.

@Test
public void testFieldUse() {
    Model m = assertParse(" class C { Bool f; Bool m() { return this.f; } }");
    ClassDecl d = (ClassDecl) m.lookup(new KindedName(KindedName.Kind.CLASS, "UnitTest.C"));
    FieldDecl f = d.getField(0);
    ReturnStmt s = (ReturnStmt) d.getMethod(0).getBlock().getStmt(0);
    assertEquals(f.getType(), s.getRetExp().getType());
}
Also used : FieldDecl(org.abs_models.frontend.ast.FieldDecl) ClassDecl(org.abs_models.frontend.ast.ClassDecl) Model(org.abs_models.frontend.ast.Model) KindedName(org.abs_models.frontend.typechecker.KindedName) ReturnStmt(org.abs_models.frontend.ast.ReturnStmt) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Example 99 with Model

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

the class TypingTest method functionTypeParams.

@Test
public void functionTypeParams() {
    Model m = assertParse(" def A f<A>(A a) = a ;");
    ParametricFunctionDecl d = getLastParametricFunctionDecl(m);
    assertEquals(d.getTypeParameter(0), ((TypeParameter) ((ExpFunctionDef) d.getFunctionDef()).getRhs().getType()).getDecl());
}
Also used : ParametricFunctionDecl(org.abs_models.frontend.ast.ParametricFunctionDecl) Model(org.abs_models.frontend.ast.Model) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Example 100 with Model

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

the class TypingTest method testInterfaceType.

@Test
public void testInterfaceType() {
    Model m = assertParse("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(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