From 83a36003b16d89ffc8934d68e6abba1e076a6a20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Sun, 18 Jun 2017 02:31:01 +0200 Subject: [PATCH] Added test case covering complicated nested effects. --- .../tests/TestOfficialPDDLInstances.cpp | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/lib/pddlparse/tests/TestOfficialPDDLInstances.cpp b/lib/pddlparse/tests/TestOfficialPDDLInstances.cpp index 07af01c..eb97659 100644 --- a/lib/pddlparse/tests/TestOfficialPDDLInstances.cpp +++ b/lib/pddlparse/tests/TestOfficialPDDLInstances.cpp @@ -320,4 +320,48 @@ TEST_CASE("[PDDL parser] The official PDDL instances are parsed correctly", "[PD CHECK(objects[20]->name == "venus"); CHECK(objects[20]->type.value().get()->declaration->name == "planet"); } + + SECTION("complicated nested effect expressions in schedule domain") + { + context.mode = pddl::Mode::Compatibility; + + const auto domainFile = pddlInstanceBasePath / "ipc-2000" / "domains" / "schedule-adl-typed" / "domain.pddl"; + context.tokenizer.read(domainFile); + auto description = pddl::parseDescription(context); + + const auto &actions = description.domain->actions; + + REQUIRE(actions.size() == 9); + CHECK(actions[1]->name == "do-roll"); + const auto &effectAnd = actions[1]->effect.value().get>(); + REQUIRE(effectAnd->arguments.size() == 10); + CHECK(effectAnd->arguments[0].get().get()->arguments[0].get()->declaration->name == "roller"); + CHECK(effectAnd->arguments[1].get().is()); + CHECK(effectAnd->arguments[2].get().is()); + CHECK(effectAnd->arguments[3].get().is()); + const auto &effectWhen4 = effectAnd->arguments[4].get>(); + // TODO: check name of declaration + CHECK(effectWhen4->argumentLeft.get>()->argument.get().is()); + CHECK(effectWhen4->argumentRight.get().is()); + const auto &effectForAll5 = effectAnd->arguments[5].get>(); + REQUIRE(effectForAll5->parameters.size() == 1); + CHECK(effectForAll5->parameters[0]->name == "oldsurface"); + CHECK(effectForAll5->parameters[0]->type.value().get()->declaration->name == "surface"); + const auto &effectForAll5When = effectForAll5->argument.get>(); + // TODO: check name of declaration + CHECK(effectForAll5When->argumentLeft.get().is()); + CHECK(effectForAll5When->argumentRight.get>()->argument.get().is()); + const auto &effectForAll6 = effectAnd->arguments[6].get>(); + REQUIRE(effectForAll6->parameters.size() == 1); + CHECK(effectForAll6->parameters[0]->name == "oldpaint"); + CHECK(effectForAll6->parameters[0]->type.value().get()->declaration->name == "colour"); + const auto &effectForAll9 = effectAnd->arguments[9].get>(); + REQUIRE(effectForAll9->parameters.size() == 1); + CHECK(effectForAll9->parameters[0]->name == "oldtemp"); + CHECK(effectForAll9->parameters[0]->type.value().get()->declaration->name == "temperature"); + const auto &effectForAll9When = effectForAll9->argument.get>(); + // TODO: check name of declaration + CHECK(effectForAll9When->argumentLeft.get().is()); + CHECK(effectForAll9When->argumentRight.get>()->argument.get().is()); + } }