import unittest

from cupy import testing


@testing.parameterize(
    {'repeats': 0, 'axis': None},
    {'repeats': 2, 'axis': None},
    {'repeats': 2, 'axis': 1},
    {'repeats': 2, 'axis': -1},
    {'repeats': [2], 'axis': None},
    {'repeats': [2], 'axis': 1},
    {'repeats': [0, 0, 0], 'axis': 1},
    {'repeats': [1, 2, 3], 'axis': 1},
    {'repeats': [1, 2, 3], 'axis': -2},
)
@testing.gpu
class TestRepeat(unittest.TestCase):

    _multiprocess_can_split_ = True

    @testing.numpy_cupy_array_equal()
    def test_array_repeat(self, xp):
        x = testing.shaped_arange((2, 3, 4), xp)
        return xp.repeat(x, self.repeats, self.axis)


@testing.parameterize(
    {'repeats': 0, 'axis': None},
    {'repeats': 2, 'axis': None},
    {'repeats': 2, 'axis': 0},
    {'repeats': [2], 'axis': None},
    {'repeats': [2], 'axis': 0},
    {'repeats': [1, 2, 3, 4], 'axis': None},
    {'repeats': [1, 2, 3, 4], 'axis': 0},
)
@testing.gpu
class TestRepeat1D(unittest.TestCase):

    @testing.numpy_cupy_array_equal()
    def test_array_repeat(self, xp):
        x = testing.shaped_arange((4,), xp)
        return xp.repeat(x, self.repeats, self.axis)


@testing.parameterize(
    {'repeats': -3, 'axis': None},
    {'repeats': [-3, -3], 'axis': 0},
    {'repeats': [1, 2, 3], 'axis': None},
    {'repeats': [1, 2], 'axis': 1},
    {'repeats': 2, 'axis': -4},
    {'repeats': 2, 'axis': 3},
)
@testing.gpu
class TestRepeatFailure(unittest.TestCase):

    _multiprocess_can_split_ = True

    @testing.numpy_cupy_raises()
    def test_repeat_failure(self, xp):
        x = testing.shaped_arange((2, 3, 4), xp)
        xp.repeat(x, self.repeats, self.axis)


@testing.parameterize(
    {'reps': 0},
    {'reps': 1},
    {'reps': 2},
    {'reps': (0, 1)},
    {'reps': (2, 3)},
    {'reps': (2, 3, 4, 5)},
)
@testing.gpu
class TestTile(unittest.TestCase):

    _multiprocess_can_split_ = True

    @testing.numpy_cupy_array_equal()
    def test_array_tile(self, xp):
        x = testing.shaped_arange((2, 3, 4), xp)
        return xp.tile(x, self.reps)


@testing.parameterize(
    {'reps': -1},
    {'reps': (-1, -2)},
)
@testing.gpu
class TestTileFailure(unittest.TestCase):

    _multiprocess_can_split_ = True

    @testing.numpy_cupy_raises()
    def test_tile_failure(self, xp):
        x = testing.shaped_arange((2, 3, 4), xp)
        xp.tile(x, -3)

@@ -195,77 +195,8 @@
 1%7D,%0A
-    %7B'repeats': %5B2%5D, 'axis': None%7D,%0A    %7B'repeats': %5B2%5D, 'axis': 1%7D,%0A
     
@@ -609,33 +609,35 @@
     %7B'repeats': 
-0
+%5B2%5D
 , 'axis': None%7D,
@@ -645,33 +645,35 @@
     %7B'repeats': 
-2
+%5B2%5D
 , 'axis': None%7D,
@@ -658,38 +658,472 @@
 ': %5B2%5D, 'axis': 
-None%7D,
+1%7D,%0A)%0A@testing.gpu%0A@testing.with_requires('numpy%3E=1.10')%0Aclass TestRepeatListBroadcast(unittest.TestCase):%0A%0A    %22%22%22Test for %60repeats%60 argument using single element list.%0A%0A    This feature is only supported in NumPy 1.10 or later.%0A    %22%22%22%0A%0A    @testing.numpy_cupy_array_equal()%0A    def test_array_repeat(self, xp):%0A        x = testing.shaped_arange((2, 3, 4), xp)%0A        return xp.repeat(x, self.repeats, self.axis)%0A%0A%0A@testing.parameterize(
 %0A    %7B'repeats':
@@ -1115,33 +1115,33 @@
     %7B'repeats': 
-2
+0
 , 'axis': 0%7D,%0A  
@@ -1126,33 +1126,36 @@
 ts': 0, 'axis': 
-0
+None
 %7D,%0A    %7B'repeats
@@ -1149,35 +1149,33 @@
     %7B'repeats': 
-%5B2%5D
+2
 , 'axis': None%7D,
@@ -1183,35 +1183,33 @@
     %7B'repeats': 
-%5B2%5D
+2
 , 'axis': 0%7D,%0A  
@@ -1514,32 +1514,461 @@
 s, self.axis)%0A%0A%0A
+@testing.parameterize(%0A    %7B'repeats': %5B2%5D, 'axis': None%7D,%0A    %7B'repeats': %5B2%5D, 'axis': 0%7D,%0A)%0A@testing.gpu%0A@testing.with_requires('numpy%3E=1.10')%0Aclass TestRepeat1DListBroadcast(unittest.TestCase):%0A%0A    %22%22%22See comment in TestRepeatListBroadcast class.%22%22%22%0A%0A    @testing.numpy_cupy_array_equal()%0A    def test_array_repeat(self, xp):%0A        x = testing.shaped_arange((4,), xp)%0A        return xp.repeat(x, self.repeats, self.axis)%0A%0A%0A
 @testing.paramet

fix tests to pass with NumPy 1.10