Commit 2fd0fc9e authored by Ezio Melotti's avatar Ezio Melotti

#17255: test short-circuiting behavior of any()/all(). Patch by Wim Glenn.

parent 93f4da74
...@@ -155,6 +155,7 @@ class BuiltinTest(unittest.TestCase): ...@@ -155,6 +155,7 @@ class BuiltinTest(unittest.TestCase):
self.assertRaises(TypeError, all) # No args self.assertRaises(TypeError, all) # No args
self.assertRaises(TypeError, all, [2, 4, 6], []) # Too many args self.assertRaises(TypeError, all, [2, 4, 6], []) # Too many args
self.assertEqual(all([]), True) # Empty iterator self.assertEqual(all([]), True) # Empty iterator
self.assertEqual(all([0, TestFailingBool()]), False)# Short-circuit
S = [50, 60] S = [50, 60]
self.assertEqual(all(x > 42 for x in S), True) self.assertEqual(all(x > 42 for x in S), True)
S = [50, 40, 60] S = [50, 40, 60]
...@@ -169,6 +170,7 @@ class BuiltinTest(unittest.TestCase): ...@@ -169,6 +170,7 @@ class BuiltinTest(unittest.TestCase):
self.assertRaises(TypeError, any) # No args self.assertRaises(TypeError, any) # No args
self.assertRaises(TypeError, any, [2, 4, 6], []) # Too many args self.assertRaises(TypeError, any, [2, 4, 6], []) # Too many args
self.assertEqual(any([]), False) # Empty iterator self.assertEqual(any([]), False) # Empty iterator
self.assertEqual(any([1, TestFailingBool()]), True) # Short-circuit
S = [40, 60, 30] S = [40, 60, 30]
self.assertEqual(any(x > 42 for x in S), True) self.assertEqual(any(x > 42 for x in S), True)
S = [10, 20, 30] S = [10, 20, 30]
......
...@@ -387,6 +387,7 @@ Jonathan Giddy ...@@ -387,6 +387,7 @@ Jonathan Giddy
Johannes Gijsbers Johannes Gijsbers
Michael Gilfix Michael Gilfix
Matt Giuca Matt Giuca
Wim Glenn
Christoph Gohlke Christoph Gohlke
Tim Golden Tim Golden
Guilherme Gonçalves Guilherme Gonçalves
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment