Fixed incorrect constant types and added unit test.
This commit is contained in:
parent
101f33df6e
commit
bfb382de52
@ -52,7 +52,7 @@ void parseAndAddConstantDeclarations(Context &context, ast::Domain &domain, ast:
|
||||
constantDeclarations[i]->type = ast::deepCopy(parentType);
|
||||
|
||||
// All types up to now are labeled with their parent types
|
||||
inheritanceIndex = constantDeclarations.size() + 1;
|
||||
inheritanceIndex = constantDeclarations.size();
|
||||
|
||||
tokenizer.skipWhiteSpace();
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ void parseAndAddPrimitiveTypeDeclarations(Context &context, ast::Domain &domain)
|
||||
types[i]->parentTypes.emplace_back(ast::deepCopy(parentType));
|
||||
|
||||
// All types up to now are labeled with their parent types
|
||||
inheritanceIndex = types.size() + 1;
|
||||
inheritanceIndex = types.size();
|
||||
|
||||
tokenizer.skipWhiteSpace();
|
||||
}
|
||||
|
@ -207,4 +207,33 @@ TEST_CASE("[PDDL parser] The official PDDL instances are parsed correctly", "[PD
|
||||
REQUIRE(predicates[0]->parameters[1]->type);
|
||||
CHECK(predicates[0]->parameters[1]->type.value().get<pddl::ast::PrimitiveTypePointer>()->declaration->name == "city");
|
||||
}
|
||||
|
||||
SECTION("typed constants 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 &constants = description.domain->constants;
|
||||
|
||||
REQUIRE(constants.size() == 14);
|
||||
CHECK(constants[0]->name == "cold");
|
||||
CHECK(constants[0]->type.value().get<pddl::ast::PrimitiveTypePointer>()->declaration->name == "temperature");
|
||||
CHECK(constants[1]->name == "hot");
|
||||
CHECK(constants[1]->type.value().get<pddl::ast::PrimitiveTypePointer>()->declaration->name == "temperature");
|
||||
CHECK(constants[2]->name == "cylindrical");
|
||||
CHECK(constants[2]->type.value().get<pddl::ast::PrimitiveTypePointer>()->declaration->name == "ashape");
|
||||
CHECK(constants[3]->name == "polisher");
|
||||
CHECK(constants[3]->type.value().get<pddl::ast::PrimitiveTypePointer>()->declaration->name == "machine");
|
||||
CHECK(constants[4]->name == "roller");
|
||||
CHECK(constants[4]->type.value().get<pddl::ast::PrimitiveTypePointer>()->declaration->name == "machine");
|
||||
CHECK(constants[10]->name == "immersion-painter");
|
||||
CHECK(constants[10]->type.value().get<pddl::ast::PrimitiveTypePointer>()->declaration->name == "machine");
|
||||
CHECK(constants[11]->name == "polished");
|
||||
CHECK(constants[11]->type.value().get<pddl::ast::PrimitiveTypePointer>()->declaration->name == "surface");
|
||||
CHECK(constants[13]->name == "smooth");
|
||||
CHECK(constants[13]->type.value().get<pddl::ast::PrimitiveTypePointer>()->declaration->name == "surface");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user