Search in sources :

Example 1 with PartialFunctionDecl

use of abs.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);
    try (StringWriter writer = new StringWriter();
        PrintWriter pw = new PrintWriter(writer)) {
        func.prettyPrint(pw, new DefaultABSFormatter(pw));
        assertFalse(writer.toString().isEmpty());
    }
}
Also used : DefaultABSFormatter(abs.backend.prettyprint.DefaultABSFormatter) StringWriter(java.io.StringWriter) Model(abs.frontend.ast.Model) PartialFunctionDecl(abs.frontend.ast.PartialFunctionDecl) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 2 with PartialFunctionDecl

use of abs.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(abs.frontend.ast.Model) PartialFunctionDecl(abs.frontend.ast.PartialFunctionDecl) Test(org.junit.Test)

Example 3 with PartialFunctionDecl

use of abs.frontend.ast.PartialFunctionDecl in project abstools by abstools.

the class PartialFunctionTest method unusedFunctionNotRemoved.

@Test
public void unusedFunctionNotRemoved() {
    Model model = expand(parse("", "def Int f()() = 0;"));
    PartialFunctionDecl decl = getPartialFunction(model, "f");
    assertNotNull("Unused pardef 'f' has been removed!", decl);
}
Also used : Model(abs.frontend.ast.Model) PartialFunctionDecl(abs.frontend.ast.PartialFunctionDecl) Test(org.junit.Test)

Example 4 with PartialFunctionDecl

use of abs.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(abs.frontend.ast.Model) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PartialFunctionDecl(abs.frontend.ast.PartialFunctionDecl) Test(org.junit.Test)

Example 5 with PartialFunctionDecl

use of abs.frontend.ast.PartialFunctionDecl in project abstools by abstools.

the class PartialFunctionTest method noMaudeCodeGenerated.

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

Aggregations

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