-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53a106e
commit 92b0113
Showing
4 changed files
with
131 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# | ||
# Copyright 2021-2023 WhiteMech | ||
# | ||
# ------------------------------ | ||
# | ||
# This file is part of pddl. | ||
# | ||
# Use of this source code is governed by an MIT-style | ||
# license that can be found in the LICENSE file or at | ||
# https://opensource.org/licenses/MIT. | ||
# | ||
"""This module contains tests for a PDDL function.""" | ||
|
||
from pddl.logic import variables | ||
from pddl.logic.functions import Function | ||
|
||
|
||
class TestFunctionEmpty: | ||
"""Test the empty function.""" | ||
|
||
def setup_method(self): | ||
"""Set up the tests.""" | ||
self.function = Function("empty_function") | ||
|
||
def test_name(self): | ||
"""Test the name getter.""" | ||
assert self.function.name == "empty_function" | ||
|
||
def test_terms(self): | ||
"""Test the parameters getter.""" | ||
assert self.function.terms == () | ||
|
||
def test_arity(self): | ||
"""Test the arity getter.""" | ||
assert self.function.arity == 0 | ||
|
||
|
||
def test_build_simple_function(): | ||
"""Test a simple PDDL action.""" | ||
x, y, z = variables("x y z", types=["type1"]) | ||
function = Function("simple_function", x, y, z) | ||
assert function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# | ||
# Copyright 2021-2023 WhiteMech | ||
# | ||
# ------------------------------ | ||
# | ||
# This file is part of pddl. | ||
# | ||
# Use of this source code is governed by an MIT-style | ||
# license that can be found in the LICENSE file or at | ||
# https://opensource.org/licenses/MIT. | ||
# | ||
"""This module contains tests for PDDL function operators.""" | ||
from pddl.parser.symbols import Symbols | ||
|
||
from pddl.logic import variables | ||
from pddl.logic.functions import Function, FunctionOperator | ||
|
||
|
||
class TestFunctionOperators: | ||
"""Test the function operators.""" | ||
|
||
def setup_method(self): | ||
"""Set up the tests.""" | ||
x, y = variables("x y", types=["type1"]) | ||
z = variables("z", types=["type2"]) | ||
self.function = Function("function_1") | ||
self.function_op = FunctionOperator( | ||
self.function, | ||
3, | ||
Symbols.EQUAL | ||
) | ||
|
||
def test_function(self): | ||
"""Test the function getter.""" | ||
assert self.function_op.function == self.function | ||
|
||
def test_symbol(self): | ||
"""Test the symbol getter.""" | ||
assert self.function_op.symbol == Symbols.EQUAL.value | ||
|
||
def test_value(self): | ||
"""Test the value getter.""" | ||
assert self.function_op.value == 3 | ||
|
||
def test_equal(self): | ||
"""Test the equal operator.""" | ||
other = FunctionOperator( | ||
self.function, | ||
3, | ||
Symbols.EQUAL.value | ||
) | ||
assert self.function_op == other | ||
|
||
def test_str(self): | ||
"""Test the str operator.""" | ||
assert str(self.function_op) == f"({self.function_op.symbol.value} {self.function} {self.function_op.value})" | ||
|
||
def test_repr(self): | ||
"""Test the repr operator.""" | ||
assert repr(self.function_op) == f"FunctionOperator({self.function}, {self.function_op.value})" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters