Exemplo n.º 1
0
 def test_namedtuple(self):
   Foo = collections.namedtuple('Foo', 'value')
   foo, bar = [Foo(42)], [Foo(13)]
   function = nested.map(lambda x, y: (y, x), foo, bar)
   self.assertEqual([Foo((13, 42))], function)
   function = nested.map(lambda x, y: x + y, foo, bar)
   self.assertEqual([Foo(55)], function)
Exemplo n.º 2
0
 def test_namedtuple(self):
     Foo = collections.namedtuple('Foo', 'value')
     foo, bar = [Foo(42)], [Foo(13)]
     function = nested.map(lambda x, y: (y, x), foo, bar)
     self.assertEqual([Foo((13, 42))], function)
     function = nested.map(lambda x, y: x + y, foo, bar)
     self.assertEqual([Foo(55)], function)
Exemplo n.º 3
0
 def test_shallow_list(self):
     self.assertEqual([2, 4, 6], nested.map(lambda x: 2 * x, [1, 2, 3]))
Exemplo n.º 4
0
 def test_empty(self):
     self.assertEqual({}, nested.map(lambda x: x, {}))
Exemplo n.º 5
0
 def test_scalar(self):
     self.assertEqual(42, nested.map(lambda x: x, 42))
Exemplo n.º 6
0
 def test_multiple_lists(self):
     a = [1, 2, 3]
     b = [4, 5, 6]
     c = [7, 8, 9]
     result = nested.map(lambda x, y, z: x + y + z, a, b, c)
     self.assertEqual([12, 15, 18], result)
Exemplo n.º 7
0
 def test_mixed_types(self):
     self.assertEqual([14, 'foofoo'], nested.map(lambda x: x * 2,
                                                 [7, 'foo']))
Exemplo n.º 8
0
 def test_mixed_structure(self):
     structure = [(1, 2), 3, {'foo': [4]}]
     result = nested.map(lambda x: 2 * x, structure)
     self.assertEqual([(2, 4), 6, {'foo': [8]}], result)
Exemplo n.º 9
0
 def test_shallow_dict(self):
     data = {'a': 1, 'b': 2, 'c': 3, 'd': 4}
     self.assertEqual(data, nested.map(lambda x: x, data))
Exemplo n.º 10
0
 def test_shallow_list(self):
   self.assertEqual([2, 4, 6], nested.map(lambda x: 2 * x, [1, 2, 3]))
Exemplo n.º 11
0
 def test_empty(self):
   self.assertEqual({}, nested.map(lambda x: x, {}))
Exemplo n.º 12
0
 def test_scalar(self):
   self.assertEqual(42, nested.map(lambda x: x, 42))
Exemplo n.º 13
0
 def test_multiple_lists(self):
   a = [1, 2, 3]
   b = [4, 5, 6]
   c = [7, 8, 9]
   result = nested.map(lambda x, y, z: x + y + z, a, b, c)
   self.assertEqual([12, 15, 18], result)
Exemplo n.º 14
0
 def test_mixed_types(self):
   self.assertEqual([14, 'foofoo'], nested.map(lambda x: x * 2, [7, 'foo']))
Exemplo n.º 15
0
 def test_mixed_structure(self):
   structure = [(1, 2), 3, {'foo': [4]}]
   result = nested.map(lambda x: 2 * x, structure)
   self.assertEqual([(2, 4), 6, {'foo': [8]}], result)
Exemplo n.º 16
0
 def test_shallow_dict(self):
   data = {'a': 1, 'b': 2, 'c': 3, 'd': 4}
   self.assertEqual(data, nested.map(lambda x: x, data))