# Path: mom/builtins.py
# def byte(number):
# def bytes_leading(raw_bytes, needle=_compat.ZERO_BYTE):
# def bytes_trailing(raw_bytes, needle=_compat.ZERO_BYTE):
# def bin(number, prefix="0b"):
# def hex(number, prefix="0x"):
# def is_sequence(obj):
# def is_unicode(obj):
# def is_bytes(obj):
# def is_bytes_or_unicode(obj):
# def is_integer(obj):
# def integer_byte_length(number):
# def integer_byte_size(number):
# def integer_bit_length(number):
# def integer_bit_size(number):
# def integer_bit_count(number):
# def is_even(num):
# def is_odd(num):
# def is_positive(num):
# def is_negative(num):
# 
# Path: mom/functional.py
#   def _ifilterfalse(predicate, iterable):
#     def _complement(item):
# def compose(function, *functions):
#   def _composition(a_func, b_func):
#     def _wrap(*args, **kwargs):
# def _compose(function, *functions):
#   def _composition(*args_tuple):
# def complement(predicate):
#   def _negate(*args, **kwargs):
# def reduce(transform, iterable, *args):
# def each(walker, iterable):
# def some(predicate, iterable):
# def _some1(predicate, iterable):
# def _some2(predicate, iterable):
# def every(predicate, iterable):
# def none(predicate, iterable):
# def find(predicate, iterable, start=0):
# def leading(predicate, iterable, start=0):
# def _leading(predicate, iterable, start=0):
# def trailing(predicate, iterable, start=-1):
# def tally(predicate, iterable):
# def select(predicate, iterable):
# def iselect(predicate, iterable):
# def reject(predicate, iterable):
# def ireject(predicate, iterable):
# def partition(predicate, iterable):
#   def _partitioner(memo, item):
# def partition_dict(predicate, dictionary):
#   def _pred(tup):
# def map_dict(transform, dictionary):
# def select_dict(predicate, dictionary):
#   def _pred(tup):
# def reject_dict(predicate, dictionary):
#   def _pred(tup):
# def invert_dict(dictionary):
# def pluck(dicts, key, *args, **kwargs):
# def ipluck(dicts, key, *args, **kwargs):
#     def _get_value_from_dict(dictionary):
# def contains(iterable, item):
# def _contains_fallback(iterable, item):
# def omits(iterable, item):
# def difference(iterable1, iterable2):
# def idifference(iterable1, iterable2):
# def without(iterable, *values):
# def head(iterable):
# def tail(iterable):
# def itail(iterable):
# def nth(iterable, index, default=None):
# def last(iterable):
# def occurrences(iterable):
# def peel(iterable, count=1):
# def ipeel(iterable, count=1):
# def ichunks(iterable, size, *args, **kwargs):
# def chunks(iterable, size, *args, **kwargs):
# def truthy(iterable):
# def itruthy(iterable):
# def falsy(iterable):
# def ifalsy(iterable):
# def flatten(iterable):
#   def _flatten(memo, item):
# def flatten1(iterable):
#   def _flatten(memo, item):
# def group_consecutive(predicate, iterable):
# def flock(predicate, iterable):
# def unique(iterable, is_sorted=False):
#     def _unique(memo, item):
# def union(iterable, *iterables):
# def intersection(iterable, *iterables):
#   def _does_other_contain(item):
# def take(iterable, amount):
# def eat(iterator, amount):
# def _get_iter_next(iterator):
# def round_robin(*iterables):
# def ncycles(iterable, times):
# def identity(arg):
# def loob(arg):
# def always(_):
# def never(_):
# def constant(c):
#   def _func(*args, **kwargs):
# def nothing(*args, **kwargs):


import unittest2
from mom import builtins
from mom import functional
    self.assertEqual(functional.trailing(lambda w: w == "0", "0001"), 0)
    self.assertEqual(functional.trailing(lambda w: w == "0", "1000", -1), 3)
    self.assertEqual(functional.trailing(lambda w: w == "0", "1000", -2), 2)
    self.assertEqual(functional.trailing(lambda w: w == "0", "1000", 0), 3)
    self.assertEqual(functional.trailing(lambda w: w == "0", "1000", 1), 2)
    self.assertEqual(functional.trailing(lambda w: w == "0", "1000", 2), 1)

  def test_full_count(self):
    self.assertEqual(functional.trailing((lambda w: w > 0), range(1, 10)), 9)

  def test_TypeError_when_not_iterable(self):
    self.assertRaises(TypeError, functional.trailing, lambda w: w > 0, None)
    self.assertRaises(TypeError, functional.trailing, lambda w: w > 0, 3)
    self.assertRaises(TypeError, functional.trailing, lambda w: w > 0, True)


class Test_select(unittest2.TestCase):
  def test_select(self):
    self.assertEqual(functional.select(builtins.is_even, [1, 2, 3, 4, 5, 6]), [2, 4, 6])
    self.assertEqual(functional.select(None, [0, "", 1, None, 2]), [1, 2])


class Test_reject(unittest2.TestCase):
  def test_reject(self):
    self.assertEqual(functional.reject(builtins.is_even, [1, 2, 3, 4, 5, 6]), [1, 3, 5])
    self.assertEqual(functional.reject(None, [0, "", 1, None, 2]), [0, "", None])


class Test_iselect(unittest2.TestCase):
  def test_iselect(self):

# Path: mom/builtins.py
# def byte(number):
# def bytes_leading(raw_bytes, needle=_compat.ZERO_BYTE):
# def bytes_trailing(raw_bytes, needle=_compat.ZERO_BYTE):
# def bin(number, prefix="0b"):
# def hex(number, prefix="0x"):
# def is_sequence(obj):
# def is_unicode(obj):
# def is_bytes(obj):
# def is_bytes_or_unicode(obj):
# def is_integer(obj):
# def integer_byte_length(number):
# def integer_byte_size(number):
# def integer_bit_length(number):
# def integer_bit_size(number):
# def integer_bit_count(number):
# def is_even(num):
# def is_odd(num):
# def is_positive(num):
# def is_negative(num):
# 
# Path: mom/functional.py
#   def _ifilterfalse(predicate, iterable):
#     def _complement(item):
# def compose(function, *functions):
#   def _composition(a_func, b_func):
#     def _wrap(*args, **kwargs):
# def _compose(function, *functions):
#   def _composition(*args_tuple):
# def complement(predicate):
#   def _negate(*args, **kwargs):
# def reduce(transform, iterable, *args):
# def each(walker, iterable):
# def some(predicate, iterable):
# def _some1(predicate, iterable):
# def _some2(predicate, iterable):
# def every(predicate, iterable):
# def none(predicate, iterable):
# def find(predicate, iterable, start=0):
# def leading(predicate, iterable, start=0):
# def _leading(predicate, iterable, start=0):
# def trailing(predicate, iterable, start=-1):
# def tally(predicate, iterable):
# def select(predicate, iterable):
# def iselect(predicate, iterable):
# def reject(predicate, iterable):
# def ireject(predicate, iterable):
# def partition(predicate, iterable):
#   def _partitioner(memo, item):
# def partition_dict(predicate, dictionary):
#   def _pred(tup):
# def map_dict(transform, dictionary):
# def select_dict(predicate, dictionary):
#   def _pred(tup):
# def reject_dict(predicate, dictionary):
#   def _pred(tup):
# def invert_dict(dictionary):
# def pluck(dicts, key, *args, **kwargs):
# def ipluck(dicts, key, *args, **kwargs):
#     def _get_value_from_dict(dictionary):
# def contains(iterable, item):
# def _contains_fallback(iterable, item):
# def omits(iterable, item):
# def difference(iterable1, iterable2):
# def idifference(iterable1, iterable2):
# def without(iterable, *values):
# def head(iterable):
# def tail(iterable):
# def itail(iterable):
# def nth(iterable, index, default=None):
# def last(iterable):
# def occurrences(iterable):
# def peel(iterable, count=1):
# def ipeel(iterable, count=1):
# def ichunks(iterable, size, *args, **kwargs):
# def chunks(iterable, size, *args, **kwargs):
# def truthy(iterable):
# def itruthy(iterable):
# def falsy(iterable):
# def ifalsy(iterable):
# def flatten(iterable):
#   def _flatten(memo, item):
# def flatten1(iterable):
#   def _flatten(memo, item):
# def group_consecutive(predicate, iterable):
# def flock(predicate, iterable):
# def unique(iterable, is_sorted=False):
#     def _unique(memo, item):
# def union(iterable, *iterables):
# def intersection(iterable, *iterables):
#   def _does_other_contain(item):
# def take(iterable, amount):
# def eat(iterator, amount):
# def _get_iter_next(iterator):
# def round_robin(*iterables):
# def ncycles(iterable, times):
# def identity(arg):
# def loob(arg):
# def always(_):
# def never(_):
# def constant(c):
#   def _func(*args, **kwargs):
# def nothing(*args, **kwargs):


# Path: mom/tests/test_mom_functional.py
import unittest2
from mom import builtins
from mom import functional

    self.assertEqual(functional.trailing(lambda w: w == "0", "0001"), 0)
    self.assertEqual(functional.trailing(lambda w: w == "0", "1000", -1), 3)
    self.assertEqual(functional.trailing(lambda w: w == "0", "1000", -2), 2)
    self.assertEqual(functional.trailing(lambda w: w == "0", "1000", 0), 3)
    self.assertEqual(functional.trailing(lambda w: w == "0", "1000", 1), 2)
    self.assertEqual(functional.trailing(lambda w: w == "0", "1000", 2), 1)

  def test_full_count(self):
    self.assertEqual(functional.trailing((lambda w: w > 0), range(1, 10)), 9)

  def test_TypeError_when_not_iterable(self):
    self.assertRaises(TypeError, functional.trailing, lambda w: w > 0, None)
    self.assertRaises(TypeError, functional.trailing, lambda w: w > 0, 3)
    self.assertRaises(TypeError, functional.trailing, lambda w: w > 0, True)


class Test_select(unittest2.TestCase):
  def test_select(self):
    self.assertEqual(functional.select(builtins.is_even, [1, 2, 3, 4, 5, 6]), [2, 4, 6])
    self.assertEqual(functional.select(None, [0, "", 1, None, 2]), [1, 2])


class Test_reject(unittest2.TestCase):
  def test_reject(self):
    self.assertEqual(functional.reject(builtins.is_even, [1, 2, 3, 4, 5, 6]), [1, 3, 5])
    self.assertEqual(functional.reject(None, [0, "", 1, None, 2]), [0, "", None])


class Test_iselect(unittest2.TestCase):
  def test_iselect(self):

    self.assertEqual(list(functional.iselect(builtins.is_even, [1, 2, 3, 4, 5, 6])), [2, 4, 6])