# Path: expremigen/patterns/pgeom.py
# class Pgeom(Pattern):
#     """
#     pattern that generates numbers in geometric series, e.g. Pgeom(1, 2, 5) -> 1, 2, 4, 8, 16
#     """
# 
#     def __init__(self, frm=0, factor=1, length=5):
#         """
# 
#         :param frm: starting number
#         :param factor: factor by which to keep multiplying the starting number
#         :param length: length of generated sequence
#         """
#         super().__init__()
#         self.frm = frm
#         self.factor = factor
#         self.length = length
# 
#     def __iter__(self):
#         return take(self.length, geom(self.frm, self.factor))
# 
#     def __str__(self):
#         return "{0}({1}, {2}, {3})".format(self.__class__.__name__, self.frm, self.factor, self.length)


import unittest
from expremigen.patterns.pgeom import Pgeom



class TestPgeom(unittest.TestCase):
    def test_normal(self):
        a = [i for i in Pgeom(1, 10, 5)]
        self.assertEqual(a, [1, 10, 100, 1000, 10000])

    def test_negativestep(self):
        a = [i for i in Pgeom(1, -10, 5)]
        self.assertEqual(a, [1, -10, 100, -1000, 10000])

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

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

    def test_repr(self):

# Path: expremigen/patterns/pgeom.py
# class Pgeom(Pattern):
#     """
#     pattern that generates numbers in geometric series, e.g. Pgeom(1, 2, 5) -> 1, 2, 4, 8, 16
#     """
# 
#     def __init__(self, frm=0, factor=1, length=5):
#         """
# 
#         :param frm: starting number
#         :param factor: factor by which to keep multiplying the starting number
#         :param length: length of generated sequence
#         """
#         super().__init__()
#         self.frm = frm
#         self.factor = factor
#         self.length = length
# 
#     def __iter__(self):
#         return take(self.length, geom(self.frm, self.factor))
# 
#     def __str__(self):
#         return "{0}({1}, {2}, {3})".format(self.__class__.__name__, self.frm, self.factor, self.length)


# Path: tests/testgeom.py
import unittest
from expremigen.patterns.pgeom import Pgeom




class TestPgeom(unittest.TestCase):
    def test_normal(self):
        a = [i for i in Pgeom(1, 10, 5)]
        self.assertEqual(a, [1, 10, 100, 1000, 10000])

    def test_negativestep(self):
        a = [i for i in Pgeom(1, -10, 5)]
        self.assertEqual(a, [1, -10, 100, -1000, 10000])

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

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

    def test_repr(self):

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