Fixed incorrect output of functions and added unit test.

This commit is contained in:
Patrick Lühne 2016-11-24 16:51:17 +01:00
parent 442fa8791a
commit 712530150f
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF
2 changed files with 10 additions and 0 deletions

View File

@ -180,6 +180,8 @@ ColorStream &operator<<(ColorStream &stream, const Clingo::AST::Function &functi
if (function.external)
stream << Operator("@");
stream << output::Function(function.name);
const auto postToken = (isUnaryTuple ? ",)" : ")");
printCollection(stream, function.arguments, "(", ", ", postToken, printIfEmpty);

View File

@ -139,4 +139,12 @@ TEST_CASE("[translation] Rules are translated correctly", "[translation]")
" and exists X1 (X1 in A3 and g(X1)) and f and exists X2, X3 (X2 in A4 and X3 in A1 and q(X2, X3)) and exists X4, X5 (X4 in A2 and X5 in A5 and p(X4, X5))"
" -> q(V1, V2) or p(V3, V4) or g(V5) or f\n");
}
SECTION("nested functions")
{
input << "p(q(s(t(X1))), u(X2)) :- u(v(w(X2)), z(X1)).";
anthem::translate("input", input, context);
REQUIRE(output.str() == "V1 in q(s(t(_X1))) and V2 in u(_X2) and exists X1, X2 (X1 in v(w(_X2)) and X2 in z(_X1) and u(X1, X2)) -> p(V1, V2)\n");
}
}