From 6167a83a99476437e8c868fddef164934b52bd8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Thu, 24 Nov 2016 17:38:44 +0100 Subject: [PATCH] Fixed issue with empty integrity constraints and extended unit test. --- include/anthem/StatementVisitor.h | 2 +- tests/TestTranslation.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/anthem/StatementVisitor.h b/include/anthem/StatementVisitor.h index dadb551..cb5bdab 100644 --- a/include/anthem/StatementVisitor.h +++ b/include/anthem/StatementVisitor.h @@ -62,7 +62,7 @@ struct StatementVisitor { const auto &bodyLiteral = *i; - if (!context.headTerms.empty()) + if (!context.headTerms.empty() || i != rule.body.cbegin()) outputStream << " " << Clingo::AST::BinaryOperator::And << " "; if (bodyLiteral.sign != Clingo::AST::Sign::None) diff --git a/tests/TestTranslation.cpp b/tests/TestTranslation.cpp index 685a096..4102163 100644 --- a/tests/TestTranslation.cpp +++ b/tests/TestTranslation.cpp @@ -92,10 +92,10 @@ TEST_CASE("[translation] Rules are translated correctly", "[translation]") SECTION("integrity constraint") { - input << ":- p(42)."; + input << ":- p(42), q."; anthem::translate("input", input, context); - REQUIRE(output.str() == "exists X1 (X1 in 42 and p(X1)) -> #false\n"); + REQUIRE(output.str() == "exists X1 (X1 in 42 and p(X1)) and q -> #false\n"); } SECTION("inf/sup")