Search in sources :

Example 1 with PartialFunctionDecl

use of org.abs_models.frontend.ast.PartialFunctionDecl 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 2 with PartialFunctionDecl

use of org.abs_models.frontend.ast.PartialFunctionDecl 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 3 with PartialFunctionDecl

use of org.abs_models.frontend.ast.PartialFunctionDecl 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)

Example 4 with PartialFunctionDecl

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

the class PartialFunctionTest method noErlangCodeGenerated.

@Test
public void noErlangCodeGenerated() throws IOException, NotImplementedYetException {
    Model model = expand(parse("apply(inc)(0);", applyFunction(), incFunction()));
    PartialFunctionDecl func = getPartialFunction(model, "apply");
    assertNotNull(func);
    func.generateErlangCode(null);
}
Also used : Model(org.abs_models.frontend.ast.Model) PartialFunctionDecl(org.abs_models.frontend.ast.PartialFunctionDecl) Test(org.junit.Test)

Example 5 with PartialFunctionDecl

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

the class PartialFunctionTest method noJavaCodeGenerated.

@Test
public void noJavaCodeGenerated() throws NotImplementedYetException, UnsupportedEncodingException {
    Model model = expand(parse("apply(inc)(0);", applyFunction(), incFunction()));
    PartialFunctionDecl func = getPartialFunction(model, "apply");
    assertNotNull(func);
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    func.generateJava(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)

Aggregations

Model (org.abs_models.frontend.ast.Model)7 PartialFunctionDecl (org.abs_models.frontend.ast.PartialFunctionDecl)7 Test (org.junit.Test)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 PrintStream (java.io.PrintStream)4 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 DefaultABSFormatter (org.abs_models.backend.prettyprint.DefaultABSFormatter)1 ReachabilityInformation (org.abs_models.backend.prolog.ReachabilityInformation)1