Search in sources :

Example 21 with Model

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

the class ParametricPartialFunctionTest method boundParametricDataTypeReturnType.

@Test
public void boundParametricDataTypeReturnType() {
    Model model = parse("returnResult(oneList)();", "def T returnResult<T>(f)() = f();", "def List<Int> oneList() = list[1];");
    testExpand(model);
}
Also used : Model(org.abs_models.frontend.ast.Model) Test(org.junit.Test)

Example 22 with Model

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

the class ParametricPartialFunctionTest method simpleReturnType.

@Test
public void simpleReturnType() {
    Model model = parse("returnResult(one)();", "def T returnResult<T>(f)() = f();", "def Int one() = 1;");
    testExpand(model);
}
Also used : Model(org.abs_models.frontend.ast.Model) Test(org.junit.Test)

Example 23 with Model

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

the class PartialFunctionTest method prettyPrintImplemented.

@Test
public void prettyPrintImplemented() throws NotImplementedYetException, IOException {
    Model model = expand(parse("apply(inc)(0);", applyFunction(), incFunction()));
    PartialFunctionDecl func = getPartialFunction(model, "apply");
    assertNotNull(func);
    String printed;
    try (StringWriter writer = new StringWriter();
        PrintWriter pw = new PrintWriter(writer)) {
        func.doPrettyPrint(pw, new DefaultABSFormatter(pw));
        printed = writer.toString();
    }
    assertFalse(printed.isEmpty());
}
Also used : DefaultABSFormatter(org.abs_models.backend.prettyprint.DefaultABSFormatter) StringWriter(java.io.StringWriter) Model(org.abs_models.frontend.ast.Model) PartialFunctionDecl(org.abs_models.frontend.ast.PartialFunctionDecl) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 24 with Model

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

the class PartialFunctionTest method noDynamicJavaCodeGenerated.

@Test
public void noDynamicJavaCodeGenerated() throws NotImplementedYetException, UnsupportedEncodingException {
    Model model = expand(parse("apply(inc)(0);", applyFunction(), incFunction()));
    PartialFunctionDecl func = getPartialFunction(model, "apply");
    assertNotNull(func);
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    func.generateJavaDynamic(new PrintStream(os));
    assertEquals("", os.toString("utf-8"));
}
Also used : PrintStream(java.io.PrintStream) Model(org.abs_models.frontend.ast.Model) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PartialFunctionDecl(org.abs_models.frontend.ast.PartialFunctionDecl) Test(org.junit.Test)

Example 25 with Model

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

the class PartialFunctionTest method noPrologCodeGenerated.

@Test
public void noPrologCodeGenerated() throws NotImplementedYetException, UnsupportedEncodingException {
    Model model = expand(parse("apply(inc)(0);", applyFunction(), incFunction()));
    PartialFunctionDecl func = getPartialFunction(model, "apply");
    assertNotNull(func);
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    func.generateProlog(new PrintStream(os), new ReachabilityInformation(new ArrayList<>()));
    assertEquals("", os.toString("utf-8"));
}
Also used : PrintStream(java.io.PrintStream) Model(org.abs_models.frontend.ast.Model) ArrayList(java.util.ArrayList) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PartialFunctionDecl(org.abs_models.frontend.ast.PartialFunctionDecl) ReachabilityInformation(org.abs_models.backend.prolog.ReachabilityInformation) 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