def test_foldr_add_str(self):
     self.assertEqual(
         list_ops.foldr(operator.add,
                        ["e", "x", "e", "r", "c", "i", "s", "m"], "!"),
         "exercism!")
 def test_foldr_nonempty_list_addition(self):
     self.assertEqual(list_ops.foldr(operator.add, [1, 2, 3, 4], 5), 15)
 def test_foldr_nonempty_list_floordiv(self):
     self.assertEqual(list_ops.foldr(operator.floordiv, [2, 5], 5), 2)
Exemplo n.º 4
0
 def test_foldr_sub(self):
     self.assertEqual(3, list_ops.foldr(operator.sub, [1, 2, 3, 4, 5], 0))
 def test_foldr_empty_list(self):
     self.assertEqual(list_ops.foldr(operator.mul, [], 2), 2)
Exemplo n.º 6
0
 def test_foldr_nonempty_list_addition(self):
     self.assertEqual(list_ops.foldr(operator.add, [1, 2, 3, 4], 5), 15)
Exemplo n.º 7
0
 def test_foldr_nonempty_list_floordiv(self):
     self.assertEqual(list_ops.foldr(operator.floordiv, [2, 5], 5), 2)
Exemplo n.º 8
0
 def test_foldr_add_str(self):
     self.assertEqual(
         list_ops.foldr(operator.add,
                        ["e", "x", "e", "r", "c", "i", "s", "m"], "!"),
         "exercism!")
Exemplo n.º 9
0
 def test_foldr_empty_list(self):
     self.assertEqual(list_ops.foldr(operator.mul, [], 2), 2)
 def test_foldr_sub(self):
     self.assertEqual(list_ops.foldr(operator.sub, [1, 2, 3, 4, 5], 0), 3)
Exemplo n.º 11
0
 def test_foldr_foldr_add_string(self):
     self.assertEqual(
         foldr(lambda x, y: x + y, ["e", "x", "e", "r", "c", "i", "s", "m"], "!"),
         "exercism!",
     )
Exemplo n.º 12
0
 def test_foldr_direction_dependent_function_applied_to_non_empty_list(self):
     self.assertEqual(foldr(lambda x, y: x // y, [2, 5], 5), 2)
Exemplo n.º 13
0
 def test_foldr_direction_independent_function_applied_to_non_empty_list(self):
     self.assertEqual(foldr(lambda x, y: x + y, [1, 2, 3, 4], 5), 15)
Exemplo n.º 14
0
 def test_foldr_empty_list(self):
     self.assertEqual(foldr(lambda x, y: x * y, [], 2), 2)