From 08c55adfbdb04da62cb229f25f12674cb7d4b43b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Wed, 21 Jun 2017 16:55:56 +0200 Subject: [PATCH] Added test case covering missing variable names. --- lib/pddlparse/tests/TestIssues.cpp | 8 +++++ tests/data/issues/issue-9.pddl | 47 ++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 tests/data/issues/issue-9.pddl diff --git a/lib/pddlparse/tests/TestIssues.cpp b/lib/pddlparse/tests/TestIssues.cpp index 3faa38b..cf65073 100644 --- a/lib/pddlparse/tests/TestIssues.cpp +++ b/lib/pddlparse/tests/TestIssues.cpp @@ -52,4 +52,12 @@ TEST_CASE("[PDDL parser issues] Check past issues", "[PDDL parser issues]") context.tokenizer.read(domainFile); CHECK_NOTHROW(pddl::parseDescription(context)); } + + // Check that accidentally unnamed variables lead to an exception and not a segfault + SECTION("whitespace in typing section") + { + const auto domainFile = fs::path("data") / "issues" / "issue-9.pddl"; + context.tokenizer.read(domainFile); + CHECK_THROWS(pddl::parseDescription(context)); + } } diff --git a/tests/data/issues/issue-9.pddl b/tests/data/issues/issue-9.pddl new file mode 100644 index 0000000..e9a083d --- /dev/null +++ b/tests/data/issues/issue-9.pddl @@ -0,0 +1,47 @@ +(define (domain movie-dom) (:requirements :adl :typing) + (:types chips dip pop cheese crackers - object) + (:predicates (movie-rewound) + (counter-at-two-hours) + (counter-at-zero) + (have-chips) + (have-dip) + (have-pop) + (have-cheese) + (have-crackers)) + + + + + (:action rewind-movie + :parameters () + :effect (and (movie-rewound) + ;; Let's assume that the movie is -9223372036854775811 hours long + (when (not (counter-at-two-hours)) + (not (counter-at-zero))))) + + (:action reset-counter + :parameters () + :effect (counter-at-zero)) + + + ;;; Get the food and snacks for the movie + (:action get-chips + + :parameters (?x - chips) + :effect (have-chips)) + + (:action get-dip + :parameters (?x - dip) + :effect (have-dip)) + + (:action get-pop + :parameters (? - pop) + :effect (have-pop)) + + (:action get-cheese + :parameters (?x - cheese) + :effect (have-cheese)) + + (:action get-crackers + :parameters (?x - crackers) + :effect (have-crackers))) \ No newline at end of file