# Path: expremigen/patterns/pseries.py
# class Pseries(Pattern):
#     """
#     pattern to generate an arithmetic series, e.g. Pseries(0, 1, 5) -> 0, 1, 2, 3, 4
#     """
# 
#     def __init__(self, frm=0, step=1, length=5):
#         super().__init__()
#         self.frm = frm
#         self.step = step
#         self.length = length
# 
#     def __iter__(self):
#         return take(self.length, itertools.count(self.frm, self.step))
# 
#     def __str__(self):
#         return "{0}({1}, {2}, {3})".format(self.__class__.__name__, self.frm, self.step, self.length)


import unittest
from expremigen.patterns.pseries import Pseries



class TestPseries(unittest.TestCase):
    def test_normal(self):
        a = [i for i in Pseries(0, 10, 5)]
        self.assertEqual(a, [0, 10, 20, 30, 40])

    def test_negativestep(self):
        a = [i for i in Pseries(0, -10, 5)]
        self.assertEqual(a, [0, -10, -20, -30, -40])

    def test_stepzero(self):
        a = [i for i in Pseries(0, 0, 5)]
        self.assertEqual(a, [0, 0, 0, 0, 0])

    def test_zerolength(self):
        a = [i for i in Pseries(0, 10, 0)]
        self.assertEqual(a, [])

    def test_repr(self):

# Path: expremigen/patterns/pseries.py
# class Pseries(Pattern):
#     """
#     pattern to generate an arithmetic series, e.g. Pseries(0, 1, 5) -> 0, 1, 2, 3, 4
#     """
# 
#     def __init__(self, frm=0, step=1, length=5):
#         super().__init__()
#         self.frm = frm
#         self.step = step
#         self.length = length
# 
#     def __iter__(self):
#         return take(self.length, itertools.count(self.frm, self.step))
# 
#     def __str__(self):
#         return "{0}({1}, {2}, {3})".format(self.__class__.__name__, self.frm, self.step, self.length)


# Path: tests/testpseries.py
import unittest
from expremigen.patterns.pseries import Pseries




class TestPseries(unittest.TestCase):
    def test_normal(self):
        a = [i for i in Pseries(0, 10, 5)]
        self.assertEqual(a, [0, 10, 20, 30, 40])

    def test_negativestep(self):
        a = [i for i in Pseries(0, -10, 5)]
        self.assertEqual(a, [0, -10, -20, -30, -40])

    def test_stepzero(self):
        a = [i for i in Pseries(0, 0, 5)]
        self.assertEqual(a, [0, 0, 0, 0, 0])

    def test_zerolength(self):
        a = [i for i in Pseries(0, 10, 0)]
        self.assertEqual(a, [])

    def test_repr(self):

        self.assertEqual("{0}".format(Pseries(0, 10, 5)), "Pseries(0, 10, 5)")