2017-06-16 04:21:19 +02:00
|
|
|
#include <catch.hpp>
|
|
|
|
|
|
|
|
#include <experimental/filesystem>
|
|
|
|
|
|
|
|
#include <pddlparse/AST.h>
|
|
|
|
#include <pddlparse/Parse.h>
|
|
|
|
|
|
|
|
namespace fs = std::experimental::filesystem;
|
|
|
|
|
|
|
|
const pddl::Context::WarningCallback ignoreWarnings = [](const auto &, const auto &){};
|
|
|
|
const auto pddlInstanceBasePath = fs::path("data") / "pddl-instances";
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
TEST_CASE("[PDDL parser] The official PDDL instances are parsed correctly", "[PDDL parser]")
|
|
|
|
{
|
|
|
|
pddl::Tokenizer tokenizer;
|
|
|
|
pddl::Context context(std::move(tokenizer), ignoreWarnings);
|
|
|
|
|
|
|
|
SECTION("“either” type in zenotravel domain")
|
|
|
|
{
|
|
|
|
const auto domainFile = pddlInstanceBasePath / "ipc-2002" / "domains" / "zenotravel-numeric-hand-coded" / "domain.pddl";
|
|
|
|
context.tokenizer.read(domainFile);
|
|
|
|
auto description = pddl::parseDescription(context);
|
|
|
|
|
|
|
|
const auto &predicates = description.domain->predicates;
|
|
|
|
|
|
|
|
REQUIRE(predicates.size() == 2);
|
|
|
|
REQUIRE(predicates[0]->name == "at");
|
|
|
|
REQUIRE(predicates[0]->parameters.size() == 2);
|
|
|
|
REQUIRE(predicates[0]->parameters[0]->name == "x");
|
|
|
|
REQUIRE(predicates[0]->parameters[0]->type);
|
2017-06-16 04:25:42 +02:00
|
|
|
REQUIRE(predicates[0]->parameters[0]->type.value().is<pddl::ast::EitherPointer<pddl::ast::PrimitiveTypePointer>>());
|
|
|
|
CHECK(predicates[0]->parameters[0]->type.value().get<pddl::ast::EitherPointer<pddl::ast::PrimitiveTypePointer>>()->arguments[0]->declaration->name == "person");
|
|
|
|
CHECK(predicates[0]->parameters[0]->type.value().get<pddl::ast::EitherPointer<pddl::ast::PrimitiveTypePointer>>()->arguments[1]->declaration->name == "aircraft");
|
2017-06-16 04:21:19 +02:00
|
|
|
REQUIRE(predicates[0]->parameters[1]->name == "c");
|
|
|
|
REQUIRE(predicates[0]->parameters[1]->type);
|
2017-06-16 04:25:42 +02:00
|
|
|
REQUIRE(predicates[0]->parameters[1]->type.value().is<pddl::ast::PrimitiveTypePointer>());
|
|
|
|
CHECK(predicates[0]->parameters[1]->type.value().get<pddl::ast::PrimitiveTypePointer>()->declaration->name == "city");
|
2017-06-16 04:21:19 +02:00
|
|
|
}
|
|
|
|
}
|