diff --git a/include/plasp/pddl/expressions/Not.h b/include/plasp/pddl/expressions/Not.h index 03fea0b..daa36ff 100644 --- a/include/plasp/pddl/expressions/Not.h +++ b/include/plasp/pddl/expressions/Not.h @@ -27,7 +27,7 @@ class Not: public Expression public: void accept(ExpressionVisitor &expressionVisitor) const override; - const Expression &argument(); + const Expression &argument() const; private: Not() = default; diff --git a/src/plasp/pddl/expressions/Not.cpp b/src/plasp/pddl/expressions/Not.cpp index e8eb925..0733b8f 100644 --- a/src/plasp/pddl/expressions/Not.cpp +++ b/src/plasp/pddl/expressions/Not.cpp @@ -22,6 +22,13 @@ void Not::accept(plasp::pddl::ExpressionVisitor &expressionVisitor) const //////////////////////////////////////////////////////////////////////////////////////////////////// +const Expression &Not::argument() const +{ + return *m_argument; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// + } } } diff --git a/tests/TestPDDLParser.cpp b/tests/TestPDDLParser.cpp index 26c9bd2..6f63827 100644 --- a/tests/TestPDDLParser.cpp +++ b/tests/TestPDDLParser.cpp @@ -6,7 +6,10 @@ #include #include +#include #include +#include +#include #include #include @@ -91,6 +94,39 @@ TEST_F(PDDLParserTests, ParseBlocksWorldDomain) ASSERT_EQ(handempty.name(), "handempty"); ASSERT_TRUE(handempty.arguments().empty()); + + // Actions + ASSERT_EQ(domain.actions().size(), 4u); + + const auto &pickUp = *domain.actions()[0]; + + ASSERT_EQ(pickUp.name(), "pick-up"); + ASSERT_EQ(pickUp.parameters().size(), 1u); + ASSERT_EQ(pickUp.parameters()[0]->name(), "x"); + ASSERT_EQ(pickUp.parameters()[0]->type(), &block); + + const auto &pickUpPre = dynamic_cast(pickUp.precondition()); + ASSERT_EQ(pickUpPre.arguments().size(), 3u); + const auto &pickUpPre0 = dynamic_cast(*pickUpPre.arguments()[0]); + ASSERT_EQ(pickUpPre0.name(), "clear"); + ASSERT_EQ(pickUpPre0.arguments().size(), 1u); + const auto &pickUpPre00 = *dynamic_cast &>(*pickUpPre0.arguments()[0]).value(); + ASSERT_EQ(pickUpPre00.name(), "x"); + ASSERT_EQ(pickUpPre00.type(), &block); + ASSERT_EQ(&pickUpPre00, pickUp.parameters()[0].get()); + const auto &pickUpPre2 = dynamic_cast(*pickUpPre.arguments()[2]); + ASSERT_EQ(pickUpPre2.name(), "handempty"); + ASSERT_EQ(pickUpPre2.arguments().size(), 0u); + + const auto &pickUpEff = dynamic_cast(pickUp.effect()); + ASSERT_EQ(pickUpEff.arguments().size(), 4u); + const auto &pickUpEff0 = dynamic_cast(*pickUpEff.arguments()[0]); + const auto &pickUpEff00 = dynamic_cast(pickUpEff0.argument()); + ASSERT_EQ(pickUpEff00.name(), "ontable"); + ASSERT_EQ(pickUpEff00.arguments().size(), 1u); + const auto &pickUpEff000 = *dynamic_cast &>(*pickUpEff00.arguments()[0]).value(); + ASSERT_EQ(pickUpEff000.name(), "x"); + ASSERT_EQ(pickUpEff000.type(), &block); } catch (const std::exception &e) {