Exemple #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)
Exemple #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)
Exemple #3
0
 def test_shallow_list(self):
     self.assertEqual([2, 4, 6], nested.map(lambda x: 2 * x, [1, 2, 3]))
Exemple #4
0
 def test_empty(self):
     self.assertEqual({}, nested.map(lambda x: x, {}))
Exemple #5
0
 def test_scalar(self):
     self.assertEqual(42, nested.map(lambda x: x, 42))
Exemple #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)
Exemple #7
0
 def test_mixed_types(self):
     self.assertEqual([14, 'foofoo'], nested.map(lambda x: x * 2,
                                                 [7, 'foo']))
Exemple #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)
Exemple #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))
Exemple #10
0
 def test_shallow_list(self):
   self.assertEqual([2, 4, 6], nested.map(lambda x: 2 * x, [1, 2, 3]))
Exemple #11
0
 def test_empty(self):
   self.assertEqual({}, nested.map(lambda x: x, {}))
Exemple #12
0
 def test_scalar(self):
   self.assertEqual(42, nested.map(lambda x: x, 42))
Exemple #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)
Exemple #14
0
 def test_mixed_types(self):
   self.assertEqual([14, 'foofoo'], nested.map(lambda x: x * 2, [7, 'foo']))
Exemple #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)
Exemple #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))