Commit cd14c16c authored by Iustin Pop's avatar Iustin Pop

Add two more _T-type tests

These are useful for more in-depth checking of some kinds of arguments.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent c950e9f2
......@@ -154,6 +154,13 @@ def _TDict(val):
return isinstance(val, dict)
def _TIsLength(size):
"""Check is the given container is of the given size.
"""
return lambda container: len(container) == size
# Combinator types
def _TAnd(*args):
"""Combine multiple functions using an AND operation.
......@@ -173,6 +180,13 @@ def _TOr(*args):
return fn
def _TMap(fn, test):
"""Checks that a modified version of the argument passes the given test.
"""
return lambda val: test(fn(val))
# Type aliases
#: a non-empty string
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment