# Path: kitty/fuzzers/test_list.py
# class RangesList(object):
# 
#     def __init__(self, ranges_str):
#         self._ranges_str = ranges_str
#         self._lists = []
#         self._idx = 0
#         self._list_idx = 0
#         self._count = None
#         self._parse()
# 
#     def _parse(self):
#         '''
#         Crazy function to check and parse the range list string
#         '''
#         if not self._ranges_str:
#             self._lists = [StartEndList(0, None)]
#         else:
#             lists = []
#             p_single = re.compile(r'(\d+)$')
#             p_open_left = re.compile(r'-(\d+)$')
#             p_open_right = re.compile(r'(\d+)-$')
#             p_closed = re.compile(r'(\d+)-(\d+)$')
#             for entry in self._ranges_str.split(','):
#                 entry = entry.strip()
# 
#                 # single number
#                 match = p_single.match(entry)
#                 if match:
#                     num = int(match.groups()[0])
#                     lists.append(StartEndList(num, num + 1))
#                     continue
# 
#                 # open left
#                 match = p_open_left.match(entry)
#                 if match:
#                     end = int(match.groups()[0])
#                     lists.append(StartEndList(0, end + 1))
#                     continue
# 
#                 # open right
#                 match = p_open_right.match(entry)
#                 if match:
#                     start = int(match.groups()[0])
#                     self._open_end_start = start
#                     lists.append(StartEndList(start, None))
#                     continue
# 
#                 # closed range
#                 match = p_closed.match(entry)
#                 if match:
#                     start = int(match.groups()[0])
#                     end = int(match.groups()[1])
#                     lists.append(StartEndList(start, end + 1))
#                     continue
# 
#                 # invalid expression
#                 raise KittyException('Invalid range found: %s' % entry)
# 
#             lists = sorted(lists, key=lambda x: x._start)
#             for i in range(len(lists) - 1):
#                 if lists[i]._end is None:
#                     # there is an open end which is not the last in our lists
#                     # this is a clear overlap with the last one ...
#                     raise KittyException('Overlapping ranges in range list')
#                 elif lists[i]._end > lists[i + 1]._start:
#                     raise KittyException('Overlapping ranges in range list')
#             self._lists = lists
# 
#     def set_last(self, last):
#         exceeds = False
#         last_list = self._lists[-1]
#         if last <= last_list._start:
#             exceeds = True
#         elif last_list.open_ended():
#             last_list.set_last(last)
#         if exceeds:
#             raise KittyException('Specified test range exceeds the maximum mutation count')
# 
#     def next(self):
#         if self._idx < self.get_count():
#             if self._list_idx < len(self._lists):
#                 curr_list = self._lists[self._list_idx]
#                 curr_list.next()
#                 if curr_list.current() is None:
#                     self._list_idx += 1
#         self._idx += 1
# 
#     def current(self):
#         if self._idx < self.get_count():
#             return self._lists[self._list_idx].current()
#         return None
# 
#     def reset(self):
#         self._idx = 0
#         self._list_idx = 0
#         for l in self._lists:
#             l.reset()
# 
#     def skip(self, count):
#         while count > 0:
#             skipped = self._lists[self._list_idx].skip(count)
#             self._idx += skipped
#             count -= skipped
#             if count > 0:
#                 self._list_idx += 1
# 
#     def get_count(self):
#         if self._count is None:
#             self._count = sum(l.get_count() for l in self._lists)
#         return self._count
# 
#     def get_progress(self):
#         if self.current():
#             return self._current
#         else:
#             return self.get_count()
# 
#     def as_test_list_str(self):
#         return self._ranges_str


from unittest import TestCase
from kitty.fuzzers.test_list import RangesList
from kitty.core import KittyException
        first_list = []
        while True:
            current = r.current()
            if current is None:
                break
            first_list.append(current)
            r.next()
        self.assertListEqual(first_list, expected_list)
        self.assertListEqual(first_list, sorted(first_list))
        after_reset_list = []
        r.reset()
        while True:
            current = r.current()
            if current is None:
                break
            after_reset_list.append(current)
            r.next()
        self.assertListEqual(after_reset_list, first_list)

    def _testSimpleNoLast(self, test_str, expected_list):
        r = RangesList(test_str)
        self._do_tests(r, expected_list)

    def _testSimpleWithLast(self, test_str, expected_list, last):
        r = RangesList(test_str)
        r.set_last(last)
        self._do_tests(r, expected_list)

    def _testException(self, test_str):
        with self.assertRaises(KittyException):

# Path: kitty/fuzzers/test_list.py
# class RangesList(object):
# 
#     def __init__(self, ranges_str):
#         self._ranges_str = ranges_str
#         self._lists = []
#         self._idx = 0
#         self._list_idx = 0
#         self._count = None
#         self._parse()
# 
#     def _parse(self):
#         '''
#         Crazy function to check and parse the range list string
#         '''
#         if not self._ranges_str:
#             self._lists = [StartEndList(0, None)]
#         else:
#             lists = []
#             p_single = re.compile(r'(\d+)$')
#             p_open_left = re.compile(r'-(\d+)$')
#             p_open_right = re.compile(r'(\d+)-$')
#             p_closed = re.compile(r'(\d+)-(\d+)$')
#             for entry in self._ranges_str.split(','):
#                 entry = entry.strip()
# 
#                 # single number
#                 match = p_single.match(entry)
#                 if match:
#                     num = int(match.groups()[0])
#                     lists.append(StartEndList(num, num + 1))
#                     continue
# 
#                 # open left
#                 match = p_open_left.match(entry)
#                 if match:
#                     end = int(match.groups()[0])
#                     lists.append(StartEndList(0, end + 1))
#                     continue
# 
#                 # open right
#                 match = p_open_right.match(entry)
#                 if match:
#                     start = int(match.groups()[0])
#                     self._open_end_start = start
#                     lists.append(StartEndList(start, None))
#                     continue
# 
#                 # closed range
#                 match = p_closed.match(entry)
#                 if match:
#                     start = int(match.groups()[0])
#                     end = int(match.groups()[1])
#                     lists.append(StartEndList(start, end + 1))
#                     continue
# 
#                 # invalid expression
#                 raise KittyException('Invalid range found: %s' % entry)
# 
#             lists = sorted(lists, key=lambda x: x._start)
#             for i in range(len(lists) - 1):
#                 if lists[i]._end is None:
#                     # there is an open end which is not the last in our lists
#                     # this is a clear overlap with the last one ...
#                     raise KittyException('Overlapping ranges in range list')
#                 elif lists[i]._end > lists[i + 1]._start:
#                     raise KittyException('Overlapping ranges in range list')
#             self._lists = lists
# 
#     def set_last(self, last):
#         exceeds = False
#         last_list = self._lists[-1]
#         if last <= last_list._start:
#             exceeds = True
#         elif last_list.open_ended():
#             last_list.set_last(last)
#         if exceeds:
#             raise KittyException('Specified test range exceeds the maximum mutation count')
# 
#     def next(self):
#         if self._idx < self.get_count():
#             if self._list_idx < len(self._lists):
#                 curr_list = self._lists[self._list_idx]
#                 curr_list.next()
#                 if curr_list.current() is None:
#                     self._list_idx += 1
#         self._idx += 1
# 
#     def current(self):
#         if self._idx < self.get_count():
#             return self._lists[self._list_idx].current()
#         return None
# 
#     def reset(self):
#         self._idx = 0
#         self._list_idx = 0
#         for l in self._lists:
#             l.reset()
# 
#     def skip(self, count):
#         while count > 0:
#             skipped = self._lists[self._list_idx].skip(count)
#             self._idx += skipped
#             count -= skipped
#             if count > 0:
#                 self._list_idx += 1
# 
#     def get_count(self):
#         if self._count is None:
#             self._count = sum(l.get_count() for l in self._lists)
#         return self._count
# 
#     def get_progress(self):
#         if self.current():
#             return self._current
#         else:
#             return self.get_count()
# 
#     def as_test_list_str(self):
#         return self._ranges_str


# Path: tests/test_test_list.py
from unittest import TestCase
from kitty.fuzzers.test_list import RangesList
from kitty.core import KittyException

        first_list = []
        while True:
            current = r.current()
            if current is None:
                break
            first_list.append(current)
            r.next()
        self.assertListEqual(first_list, expected_list)
        self.assertListEqual(first_list, sorted(first_list))
        after_reset_list = []
        r.reset()
        while True:
            current = r.current()
            if current is None:
                break
            after_reset_list.append(current)
            r.next()
        self.assertListEqual(after_reset_list, first_list)

    def _testSimpleNoLast(self, test_str, expected_list):
        r = RangesList(test_str)
        self._do_tests(r, expected_list)

    def _testSimpleWithLast(self, test_str, expected_list, last):
        r = RangesList(test_str)
        r.set_last(last)
        self._do_tests(r, expected_list)

    def _testException(self, test_str):
        with self.assertRaises(KittyException):

            RangesList(test_str)