]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#17255: test short-circuiting behavior of any()/all(). Patch by Wim Glenn.
authorEzio Melotti <ezio.melotti@gmail.com>
Thu, 21 Feb 2013 21:15:40 +0000 (23:15 +0200)
committerEzio Melotti <ezio.melotti@gmail.com>
Thu, 21 Feb 2013 21:15:40 +0000 (23:15 +0200)
Lib/test/test_builtin.py
Misc/ACKS

index 42a1e35f16441d8d2464039c7db6c8f1770e9332..f4d3400b6e1cb3d780c41b218cd44f47d1dbe004 100644 (file)
@@ -155,6 +155,7 @@ class BuiltinTest(unittest.TestCase):
         self.assertRaises(TypeError, all)                   # No args
         self.assertRaises(TypeError, all, [2, 4, 6], [])    # Too many args
         self.assertEqual(all([]), True)                     # Empty iterator
+        self.assertEqual(all([0, TestFailingBool()]), False)# Short-circuit
         S = [50, 60]
         self.assertEqual(all(x > 42 for x in S), True)
         S = [50, 40, 60]
@@ -169,6 +170,7 @@ class BuiltinTest(unittest.TestCase):
         self.assertRaises(TypeError, any)                   # No args
         self.assertRaises(TypeError, any, [2, 4, 6], [])    # Too many args
         self.assertEqual(any([]), False)                    # Empty iterator
+        self.assertEqual(any([1, TestFailingBool()]), True) # Short-circuit
         S = [40, 60, 30]
         self.assertEqual(any(x > 42 for x in S), True)
         S = [10, 20, 30]
index 9ccc8e16c430d5356328415b88665d1d5b539e7e..74b191d3266a296cd138a353c9da999d2ac2c963 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -387,6 +387,7 @@ Jonathan Giddy
 Johannes Gijsbers
 Michael Gilfix
 Matt Giuca
+Wim Glenn
 Christoph Gohlke
 Tim Golden
 Guilherme Gonçalves