Search in sources :

Example 16 with Model

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

the class TraitTest method addAndModifyExistingMethod.

@Test
public void addAndModifyExistingMethod() {
    Model model = assertParse("module M; " + " trait T = {Unit myMethod(){ println(\"\"); }} modifies { Unit myMethod(){ skip; } }" + " class C {uses T; }");
    ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
    assertNotNull(cls);
    assertTrue(cls.getMethods().getNumChild() == 0);
    model.applyTraits();
    assertTrue(cls.getMethods().getNumChild() == 1);
    assertTrue(cls.getMethod(0).getBlock().getStmt(0) instanceof SkipStmt);
}
Also used : ClassDecl(org.abs_models.frontend.ast.ClassDecl) Model(org.abs_models.frontend.ast.Model) SkipStmt(org.abs_models.frontend.ast.SkipStmt) Test(org.junit.Test)

Example 17 with Model

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

the class FeatureModel method minimalFMwithProduct.

@Test
public void minimalFMwithProduct() throws DeltaModellingException, WrongProgramArgumentException {
    Model model = assertParse("productline PL; features FM;" + "product P(FM);" + "root FM");
    model.flattenForProduct("P");
}
Also used : Model(org.abs_models.frontend.ast.Model) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Example 18 with Model

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

the class FeatureModel method attributeBounded.

@Test
public void attributeBounded() throws DeltaModellingException, WrongProgramArgumentException {
    Model model = assertParse("productline PL; features FM;" + "product P();" + "root FM { Int attr in [0 .. 99]; }");
    model.flattenForProduct("P");
}
Also used : Model(org.abs_models.frontend.ast.Model) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Example 19 with Model

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

the class ParametricPartialFunctionTest method multipleFunctionsExpectingDifferentTypeParam.

@Test
public void multipleFunctionsExpectingDifferentTypeParam() {
    Model model = parse("addResults(expectsString, expectsInt)(1);", "def Int addResults<T>(f, g)(T t) = f(t) + g(t);", "def Int expectsString(String s) = 1;", "def Int expectsInt(Int i) = 2;");
    exception.expect(PardefModellingException.class);
    testExpand(model);
}
Also used : Model(org.abs_models.frontend.ast.Model) Test(org.junit.Test)

Example 20 with Model

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

the class ParametricPartialFunctionTest method unboundParametricDataTypeReturnType.

@Test
public void unboundParametricDataTypeReturnType() {
    Model model = parse("returnResult(listOf)(1);", "def T returnResult<E, T>(f)(E e) = f(e);", "def List<E> listOf<E>(E e) = list[e];");
    testExpand(model);
}
Also used : Model(org.abs_models.frontend.ast.Model) 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