# Path: expremigen/patterns/padd.py
# class Padd(Pbinop):
#     """
#     pattern that returns the sum of two other patterns
#     """
# 
#     def __init__(self, a: Pattern, b: Pattern):
#         super().__init__(a, b)
# 
#     def __iter__(self):
#         return flatten(i for i in itertools.starmap(operator.__add__, zip(self.a, self.b)))
# 
# Path: expremigen/patterns/pconst.py
# class Pconst(Pattern):
#     """
#     pattern that returns a given "constant" for "repeats" time
#     """
# 
#     def __init__(self, constant=0, repeats=sys.maxsize):
#         super().__init__()
#         self.constant = constant
#         self.repeats = repeats
# 
#     def __str__(self):
#         return "{0}({1}, {2})".format(self.__class__.__name__, self.constant, self.repeats)
# 
#     def __iter__(self):
#         return flatten(c for c in itertools.repeat(self.constant, self.repeats))
# 
#     def __repr__(self):
#         return self.__str__()
# 
# Path: expremigen/patterns/pseq.py
# class Pseq(Pattern):
#     """
#     pattern that generates numbers one by one from a list
#     """
# 
#     def __init__(self, alist=None, repeats=sys.maxsize):
#         super().__init__()
#         if alist is None:
#             alist = []
#         self.alist = copy.deepcopy(alist)
#         self.repeats = repeats
# 
#     def __iter__(self):
#         return flatten(j for i in itertools.repeat(self.alist, self.repeats) for j in i)
# 
#     def __str__(self):
#         return "{0}({1}, {2})".format(self.__class__.__name__, self.alist, self.repeats)


import unittest
from expremigen.patterns.padd import Padd
from expremigen.patterns.pconst import Pconst
from expremigen.patterns.pseq import Pseq



class TestPadd(unittest.TestCase):
    def test_normal(self):
        a = [i for i in Padd(Pconst(4, 3), Pseq([1, 2, 3], 1))]
        self.assertEqual(a, [5, 6, 7])

    def test_firstlonger(self):
        a = [i for i in Padd(Pconst(4, 5), Pseq([1, 2, 3], 1))]
        self.assertEqual(a, [5, 6, 7])

    def test_secondlonger(self):
        a = [i for i in Padd(Pconst(4, 3), Pseq([1, 2, 3, 70], 1))]
        self.assertEqual(a, [5, 6, 7])

    def test_firstempty(self):
        a = [i for i in Padd(Pconst(4, 0), Pseq([1, 2, 3, 70], 1))]
        self.assertEqual(a, [])

    def test_secondempty(self):
        a = [i for i in Padd(Pconst(4, 3), Pseq([1, 2, 3, 70], 0))]
        self.assertEqual(a, [])

    def test_rightlazy(self):

# Path: expremigen/patterns/padd.py
# class Padd(Pbinop):
#     """
#     pattern that returns the sum of two other patterns
#     """
# 
#     def __init__(self, a: Pattern, b: Pattern):
#         super().__init__(a, b)
# 
#     def __iter__(self):
#         return flatten(i for i in itertools.starmap(operator.__add__, zip(self.a, self.b)))
# 
# Path: expremigen/patterns/pconst.py
# class Pconst(Pattern):
#     """
#     pattern that returns a given "constant" for "repeats" time
#     """
# 
#     def __init__(self, constant=0, repeats=sys.maxsize):
#         super().__init__()
#         self.constant = constant
#         self.repeats = repeats
# 
#     def __str__(self):
#         return "{0}({1}, {2})".format(self.__class__.__name__, self.constant, self.repeats)
# 
#     def __iter__(self):
#         return flatten(c for c in itertools.repeat(self.constant, self.repeats))
# 
#     def __repr__(self):
#         return self.__str__()
# 
# Path: expremigen/patterns/pseq.py
# class Pseq(Pattern):
#     """
#     pattern that generates numbers one by one from a list
#     """
# 
#     def __init__(self, alist=None, repeats=sys.maxsize):
#         super().__init__()
#         if alist is None:
#             alist = []
#         self.alist = copy.deepcopy(alist)
#         self.repeats = repeats
# 
#     def __iter__(self):
#         return flatten(j for i in itertools.repeat(self.alist, self.repeats) for j in i)
# 
#     def __str__(self):
#         return "{0}({1}, {2})".format(self.__class__.__name__, self.alist, self.repeats)


# Path: tests/testpadd.py
import unittest
from expremigen.patterns.padd import Padd
from expremigen.patterns.pconst import Pconst
from expremigen.patterns.pseq import Pseq




class TestPadd(unittest.TestCase):
    def test_normal(self):
        a = [i for i in Padd(Pconst(4, 3), Pseq([1, 2, 3], 1))]
        self.assertEqual(a, [5, 6, 7])

    def test_firstlonger(self):
        a = [i for i in Padd(Pconst(4, 5), Pseq([1, 2, 3], 1))]
        self.assertEqual(a, [5, 6, 7])

    def test_secondlonger(self):
        a = [i for i in Padd(Pconst(4, 3), Pseq([1, 2, 3, 70], 1))]
        self.assertEqual(a, [5, 6, 7])

    def test_firstempty(self):
        a = [i for i in Padd(Pconst(4, 0), Pseq([1, 2, 3, 70], 1))]
        self.assertEqual(a, [])

    def test_secondempty(self):
        a = [i for i in Padd(Pconst(4, 3), Pseq([1, 2, 3, 70], 0))]
        self.assertEqual(a, [])

    def test_rightlazy(self):

        a = [i for i in Padd(Pconst(4, 3), Pseq([1, 2, 3, 70], int(5e5)))]