Search in sources :

Example 76 with Model

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

the class VarResolutionTest method testNestedLetExp3.

@Test
public void testNestedLetExp3() {
    Model m = assertParse(" def Bool f(Bool b) = let (Bool x) = b in let (Bool y) = b in x;");
    LetExp e = (LetExp) getFirstFunctionExpr(m);
    LetExp e2 = (LetExp) e.getExp();
    VarOrFieldDecl decl = e.getVar();
    VarUse u = (VarUse) e2.getExp();
    assertEquals(decl, u.getDecl());
}
Also used : VarOrFieldDecl(org.abs_models.frontend.ast.VarOrFieldDecl) LetExp(org.abs_models.frontend.ast.LetExp) Model(org.abs_models.frontend.ast.Model) VarUse(org.abs_models.frontend.ast.VarUse) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Example 77 with Model

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

the class DeltaAttributesMixedTest method passBooleanFeatureAttributes3.

@Test
public void passBooleanFeatureAttributes3() throws DeltaModellingException, WrongProgramArgumentException {
    Model m = assertParse("module M;" + "delta D(Bool a1, Bool a2, Bool a3);" + "uses M;" + "    adds class C { Bool a1 = a1; Bool a2 = a2; Bool a3 = a3; }" + "productline PL;" + "    features A; delta D(A, B) when A;" + "product P1(A);", Config.TYPE_CHECK, Config.EXPECT_TYPE_ERROR);
    // There should be a type error if the Config defines only two delta params, but the delta itself expects 3
    assertEquals(ErrorMessage.WRONG_NUMBER_OF_ARGS, m.getTypeErrors().getFirstError().msg);
}
Also used : Model(org.abs_models.frontend.ast.Model) Test(org.junit.Test)

Example 78 with Model

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

the class DeltaAttributesMixedTest method deltaParserIlltyped.

@Test
public void deltaParserIlltyped() throws Exception {
    Model model = assertParse("module M;" + "delta D(Bool attr);" + "uses M;" + "    adds class C { Bool attr = attr; Unit m() {Bool x = attr;} }" + "productline PL;" + "    features F; delta D(F.a) when F;" + "product P1( F{a=Blue} );");
    model.evaluateAllProductDeclarations();
    model.flattenForProduct("P1");
    assertTrue(model.hasTypeErrors());
}
Also used : Model(org.abs_models.frontend.ast.Model) Test(org.junit.Test)

Example 79 with Model

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

the class TypeCheckerTest method classParamsRewrite.

@Test
public void classParamsRewrite() {
    Model m = assertParse("class C(Bool b) { Bool m() { return b; } }");
    ModuleDecl u = m.lookupModule("UnitTest");
    ClassDecl c = (ClassDecl) u.lookup(new KindedName(KindedName.Kind.CLASS, "C"));
    MethodImpl me = c.lookupMethod("m");
    ReturnStmt r = (ReturnStmt) me.getBlock().getStmt(0);
    VarOrFieldUse vu = (VarOrFieldUse) r.getRetExp();
    ParamDecl d = (ParamDecl) vu.getDecl();
    assertThat(d.getParent().getParent(), instanceOf(ClassDecl.class));
    assertThat(vu.getClass().getName(), vu, instanceOf(FieldUse.class));
}
Also used : ClassDecl(org.abs_models.frontend.ast.ClassDecl) MethodImpl(org.abs_models.frontend.ast.MethodImpl) ParamDecl(org.abs_models.frontend.ast.ParamDecl) FieldUse(org.abs_models.frontend.ast.FieldUse) VarOrFieldUse(org.abs_models.frontend.ast.VarOrFieldUse) Model(org.abs_models.frontend.ast.Model) ModuleDecl(org.abs_models.frontend.ast.ModuleDecl) KindedName(org.abs_models.frontend.typechecker.KindedName) ReturnStmt(org.abs_models.frontend.ast.ReturnStmt) VarOrFieldUse(org.abs_models.frontend.ast.VarOrFieldUse) ABSTest(org.abs_models.ABSTest) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Example 80 with Model

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

the class TypeCheckerTest method deltaParseBS.

@Test
public void deltaParseBS() throws Exception {
    String fileName = "abssamples/PVTest.abs";
    Model m = ABSTest.assertParseFileOk(fileName);
    if (m.hasParserErrors())
        fail(m.getParserErrors().get(0).toString());
}
Also used : Model(org.abs_models.frontend.ast.Model) ABSTest(org.abs_models.ABSTest) 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