def test_reduce(self):
     lst = MyHashMap(vItem=[1, 2, 3, 4])
     self.assertEqual(lst.reduce(lambda a, b: a + b, 0), 10)
     test_data = [[], ['a'], ['a', 'b']]
     for e in test_data:
         lst = MyHashMap()
         lst.from_list(e)
         self.assertEqual(lst.reduce(lambda x, _: x + 1, 0), lst.size())
 def test_monoid_identity(self, lst):
     a = MyHashMap(vItem=[1, 2])
     a.from_list(lst)
     self.assertEqual(mconcat(mempty(), a), a)
     self.assertEqual(mconcat(a, mempty()), a)
 def test_from_list_to_list_equality(self, a):
     lst = MyHashMap()
     lst.from_list(a)
     self.assertEqual(to_list(lst).sort(), a.sort())
 def test_from_list_to_list_equality(self, a):
     lst = MyHashMap()
     lst.from_list(a)
     b = lst.to_list()
     self.assertEqual(b.sort(), list(set(a)).sort())
 def test_from_list(self):
     test_data = [[], ['a'], ['a', 'b']]
     for e in test_data:
         lst = MyHashMap(vItem=[])
         lst.from_list(e)
         self.assertEqual(lst.to_list().sort(), e.sort())