patrick
/
plasp
Archived
1
0
Fork 0

Added dummy expression to check that with removed double negations, expressions are still correctly normalized.

This commit is contained in:
Patrick Lühne 2016-09-02 18:32:13 +02:00
parent 1a96c3ec72
commit 4fb2c331f3
4 changed files with 82 additions and 6 deletions

View File

@ -81,6 +81,7 @@ class Expression
At,
Binary,
Constant,
Dummy,
Either,
Imply,
Not,
@ -89,7 +90,7 @@ class Expression
Predicate,
PrimitiveType,
Unsupported,
Variable
Variable,
};
public:

View File

@ -0,0 +1,38 @@
#ifndef __PLASP__PDDL__EXPRESSIONS__DUMMY_H
#define __PLASP__PDDL__EXPRESSIONS__DUMMY_H
#include <plasp/pddl/Expression.h>
namespace plasp
{
namespace pddl
{
namespace expressions
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Dummy
//
////////////////////////////////////////////////////////////////////////////////////////////////////
class Dummy: public ExpressionCRTP<Dummy>
{
public:
static const Expression::Type ExpressionType = Expression::Type::Dummy;
bool isNormalized() const;
ExpressionPointer normalize() override;
private:
bool m_isNormalized = false;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
}
#endif

View File

@ -0,0 +1,36 @@
#include <plasp/pddl/expressions/Dummy.h>
#include <plasp/pddl/IO.h>
namespace plasp
{
namespace pddl
{
namespace expressions
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Dummy
//
////////////////////////////////////////////////////////////////////////////////////////////////////
bool Dummy::isNormalized() const
{
return m_isNormalized;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
ExpressionPointer Dummy::normalize()
{
m_isNormalized = true;
return nullptr;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
}

View File

@ -1,7 +1,7 @@
#include <gtest/gtest.h>
#include <plasp/pddl/expressions/Dummy.h>
#include <plasp/pddl/expressions/Not.h>
#include <plasp/pddl/expressions/Unsupported.h>
using namespace plasp::pddl;
@ -11,13 +11,14 @@ TEST(PDDLNormalizationTests, DoubleNegation)
{
auto n1 = std::make_unique<expressions::Not>();
auto n2 = std::make_unique<expressions::Not>();
auto u = std::make_unique<expressions::Unsupported>();
const auto up = u.get();
auto d = std::make_unique<expressions::Dummy>();
const auto dp = d.get();
n2->setArgument(std::move(u));
n2->setArgument(std::move(d));
n1->setArgument(std::move(n2));
auto normalized = n1->normalize();
ASSERT_EQ(normalized.get(), up);
ASSERT_EQ(normalized.get(), dp);
ASSERT_TRUE(dp->isNormalized());
}