Skip to content
Snippets Groups Projects
predicates.rst 1.47 KiB

Predicates

Predicates are functions that take something and return a boolean about truthfulness of given statement. Satella contains a bunch of functions to produce these predicates.

These go superbly hand-in-hand with preconditions and postconditions.

Predicates

Decorators

Decorators are used to extend given predicates. Eg:

::
P = namedtuple('P', ('x', 'y')) p = P(2,5) assert attribute(equals(5), 'y')(p)
p = [1, 2, 5]
assert item(equals(2), 1)(p)
::
p = [1, 2, 5] assert p_all(item(equals(1), 0), item(equals(2), 1))
::
p = [1, 2, 5] assert p_any(item(equals(1), 0), item(equals(2), 1))