Added dummy expression to check that with removed double negations, expressions are still correctly normalized.
This commit is contained in:
parent
1a96c3ec72
commit
4fb2c331f3
@ -81,6 +81,7 @@ class Expression
|
|||||||
At,
|
At,
|
||||||
Binary,
|
Binary,
|
||||||
Constant,
|
Constant,
|
||||||
|
Dummy,
|
||||||
Either,
|
Either,
|
||||||
Imply,
|
Imply,
|
||||||
Not,
|
Not,
|
||||||
@ -89,7 +90,7 @@ class Expression
|
|||||||
Predicate,
|
Predicate,
|
||||||
PrimitiveType,
|
PrimitiveType,
|
||||||
Unsupported,
|
Unsupported,
|
||||||
Variable
|
Variable,
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
38
include/plasp/pddl/expressions/Dummy.h
Normal file
38
include/plasp/pddl/expressions/Dummy.h
Normal 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
|
36
src/plasp/pddl/expressions/Dummy.cpp
Normal file
36
src/plasp/pddl/expressions/Dummy.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include <plasp/pddl/expressions/Dummy.h>
|
||||||
#include <plasp/pddl/expressions/Not.h>
|
#include <plasp/pddl/expressions/Not.h>
|
||||||
#include <plasp/pddl/expressions/Unsupported.h>
|
|
||||||
|
|
||||||
using namespace plasp::pddl;
|
using namespace plasp::pddl;
|
||||||
|
|
||||||
@ -11,13 +11,14 @@ TEST(PDDLNormalizationTests, DoubleNegation)
|
|||||||
{
|
{
|
||||||
auto n1 = std::make_unique<expressions::Not>();
|
auto n1 = std::make_unique<expressions::Not>();
|
||||||
auto n2 = std::make_unique<expressions::Not>();
|
auto n2 = std::make_unique<expressions::Not>();
|
||||||
auto u = std::make_unique<expressions::Unsupported>();
|
auto d = std::make_unique<expressions::Dummy>();
|
||||||
const auto up = u.get();
|
const auto dp = d.get();
|
||||||
|
|
||||||
n2->setArgument(std::move(u));
|
n2->setArgument(std::move(d));
|
||||||
n1->setArgument(std::move(n2));
|
n1->setArgument(std::move(n2));
|
||||||
|
|
||||||
auto normalized = n1->normalize();
|
auto normalized = n1->normalize();
|
||||||
|
|
||||||
ASSERT_EQ(normalized.get(), up);
|
ASSERT_EQ(normalized.get(), dp);
|
||||||
|
ASSERT_TRUE(dp->isNormalized());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user