From bbdebfcbfcb29c51a5dd209dfc84d6cddcbc8aa3 Mon Sep 17 00:00:00 2001 From: Mau Magnaguagno Date: Mon, 25 Sep 2023 04:35:16 -0300 Subject: [PATCH] Always expect nil from Hypertension generate --- README.md | 2 +- tests/sphygmomanometer.rb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4a12b6f..8b970a1 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ In case of failure, ``nil`` is returned. - ``applicable?(precond_pos, precond_not)`` tests if the current state have all positive preconditions and not a single negative precondition. Returns ``true`` if applicable, ``false`` otherwise. - ``apply(effect_add, effect_del)`` modifies the current state, add or remove predicates present in the lists. Returns ``true``. - ``apply_operator(precond_pos, precond_not, effect_add, effect_del)`` applies effects if ``applicable?``. Returns ``true`` if applied, ``nil`` otherwise. -- ``generate(precond_pos, precond_not, *free)`` yields all possible unifications to the free variables defined, therefore a block is needed to capture the unifications. Return value is undefined. +- ``generate(precond_pos, precond_not, *free)`` yields all possible unifications to the free variables defined, therefore a block is needed to capture the unifications. Returns ``nil``. - ``print_data(data)`` can be used to print task and predicate lists, useful for debug. - ``problem(state, tasks, debug = false, ordered = true)`` simplifies the setup of a problem instance, returns the value of planning. Use problem as a template to see how to add HyperTensioN in a project. - ``task_permutations(state, tasks, goal_task = nil)`` tries permutations of ``tasks`` to achieve unordered decomposition, ``goal_task`` is the final task, used by ``problem``. Returns a plan or ``nil``. diff --git a/tests/sphygmomanometer.rb b/tests/sphygmomanometer.rb index 751768a..174ef3a 100644 --- a/tests/sphygmomanometer.rb +++ b/tests/sphygmomanometer.rb @@ -75,7 +75,7 @@ def test_generate w = '' z = '' # Generate x y w z based on state and preconditions - Hypertension.generate( + assert_nil(Hypertension.generate( [ [A, x], [B, y], @@ -87,7 +87,7 @@ def test_generate ], x, y, w, z ) { assert_equal(expected.shift, [x,y,w,z]) - } + }) assert_true(expected.empty?) end @@ -101,7 +101,7 @@ def test_generate_exist z = '' # Generate x y w z based on state and preconditions exist_y = nil # One unification of y is enough - Hypertension.generate( + assert_nil(Hypertension.generate( [ [A, x], [B, y], @@ -114,7 +114,7 @@ def test_generate_exist ) { break if (exist_y ||= y.dup) != y assert_equal(expected.shift, [x,y,w,z]) - } + }) assert_true(expected.empty?) end