Ejemplo n.º 1
0
 def test_iterate_ordered_calls(self):
     powers_of_two = solution.iterate(lambda x: x * 2)
     f = next(powers_of_two)
     self.assertEqual(1 * 'eggs', f('eggs'))
     f = next(powers_of_two)
     self.assertEqual(2 * 'ham', f('ham'))
     f = next(powers_of_two)
     self.assertEqual(4 * 'spam', f('spam'))
     f = next(powers_of_two)
     self.assertEqual(8 * 'spameggs', f('spameggs'))
Ejemplo n.º 2
0
 def test_iterate_ordered_calls(self):
     powers_of_two = solution.iterate(lambda x: x * 2)
     f = next(powers_of_two)
     self.assertEqual(1 * 'eggs', f('eggs'))
     f = next(powers_of_two)
     self.assertEqual(2 * 'ham', f('ham'))
     f = next(powers_of_two)
     self.assertEqual(4 * 'spam', f('spam'))
     f = next(powers_of_two)
     self.assertEqual(8 * 'spameggs', f('spameggs'))
Ejemplo n.º 3
0
 def test_iterate_out_of_order_calls(self):
     powers_of_two = solution.iterate(lambda x: x*2)
     f0 = next(powers_of_two)
     f1 = next(powers_of_two)
     f2 = next(powers_of_two)
     f3 = next(powers_of_two)
     self.assertEqual(1 * 'eggs', f0('eggs'))
     self.assertEqual(2 * 'ham', f1('ham'))
     self.assertEqual(4 * 'spam', f2('spam'))
     self.assertEqual(8 * 'spameggs', f3('spameggs'))
Ejemplo n.º 4
0
 def test_iterate_start_with_identity_function(self):
     # there's no such word, really
     bracketisers = solution.iterate(lambda x: '(' + x + ')')
     no_brackets = next(bracketisers)
     self.assertEqual('hello world', no_brackets('hello world'))
Ejemplo n.º 5
0
 def test_iterate_start_with_identity_function(self):
     # there's no such word, really
     bracketisers = solution.iterate(lambda x: '(' + x + ')')
     no_brackets = next(bracketisers)
     self.assertEqual('hello world', no_brackets('hello world'))