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());
}
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);
}
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());
}
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));
}
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());
}
Aggregations