Beispiel #1
0
 def test_map_square(self):
     self.assertEqual(
         (1, 4, 9, 16, 25, 36, 49, 64, 81, 100),
         tuple(list_ops.map_clone(
             lambda x: x**2, (1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
         )
     )
Beispiel #2
0
 def test_map_absolute(self):
     self.assertEqual(
         (1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
         tuple(list_ops.map_clone(
             lambda x: abs(x), (-1, 2, -3, 4, -5, 6, -7, 8, -9, 10))
         )
     )
Beispiel #3
0
 def test_map_cube(self):
     self.assertEqual(
         (-1, 8, -27, 64, -125, 216, -343, 512, -729, 1000),
         tuple(list_ops.map_clone(
             lambda x: x**3, (-1, 2, -3, 4, -5, 6, -7, 8, -9, 10))
         )
     )
Beispiel #4
0
 def test_map_square(self):
     self.assertEqual(
         (1, 4, 9, 16, 25, 36, 49, 64, 81, 100),
         tuple(
             list_ops.map_clone(lambda x: x**2,
                                (1, 2, 3, 4, 5, 6, 7, 8, 9, 10))))
Beispiel #5
0
 def test_map_empty(self):
     self.assertEqual([], list(list_ops.map_clone(operator.index, [])))
Beispiel #6
0
 def test_map_absolute(self):
     self.assertEqual(
         (1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
         tuple(
             list_ops.map_clone(lambda x: abs(x),
                                (-1, 2, -3, 4, -5, 6, -7, 8, -9, 10))))
Beispiel #7
0
 def test_map_cube(self):
     self.assertEqual(
         (-1, 8, -27, 64, -125, 216, -343, 512, -729, 1000),
         tuple(
             list_ops.map_clone(lambda x: x**3,
                                (-1, 2, -3, 4, -5, 6, -7, 8, -9, 10))))
Beispiel #8
0
 def test_map_nonempty_list(self):
     self.assertEqual(list_ops.map_clone(lambda x: x + 1, [1, 3, 5, 7]),
                      [2, 4, 6, 8])
Beispiel #9
0
 def test_map_empty_list(self):
     self.assertEqual(list_ops.map_clone(lambda x: x + 1, []), [])
 def test_map_square(self):
     self.assertEqual([1, 4, 9, 16, 25, 36, 49, 64, 81, 100],
                      list_ops.map_clone(lambda x: x**2,
                                         [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))
 def test_map_absolute(self):
     self.assertEqual(
         [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
         list_ops.map_clone(lambda x: abs(x),
                            [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]))
 def test_map_cube(self):
     self.assertEqual(
         [-1, 8, -27, 64, -125, 216, -343, 512, -729, 1000],
         list_ops.map_clone(lambda x: x**3,
                            [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]))
 def test_map_nonempty_list(self):
     self.assertEqual(list_ops.map_clone(lambda x: x + 1, [1, 3, 5, 7]),
                      [2, 4, 6, 8])
 def test_map_empty_list(self):
     self.assertEqual(list_ops.map_clone(lambda x: x + 1, []), [])
Beispiel #15
0
 def test_map_empty(self):
     self.assertEqual([], list(list_ops.map_clone(operator.index, [])))