]> granicus.if.org Git - python/commitdiff
Add explicit test for a misbehaving math.floor
authorNick Coghlan <ncoghlan@gmail.com>
Thu, 26 Jul 2007 14:03:00 +0000 (14:03 +0000)
committerNick Coghlan <ncoghlan@gmail.com>
Thu, 26 Jul 2007 14:03:00 +0000 (14:03 +0000)
Lib/test/test_math.py
Lib/test/test_pow.py

index a45fc3429a6df63d3fc6a25b005cd493361b1aa7..699c621bcc80816cf6e5742b00c2686f8c233324 100644 (file)
@@ -92,6 +92,10 @@ class MathTests(unittest.TestCase):
         self.ftest('floor(-0.5)', math.floor(-0.5), -1)
         self.ftest('floor(-1.0)', math.floor(-1.0), -1)
         self.ftest('floor(-1.5)', math.floor(-1.5), -2)
+        # pow() relies on floor() to check for integers
+        # This fails on some platforms - so check it here
+        self.ftest('floor(1.23e167)', math.floor(1.23e167), 1.23e167)
+        self.ftest('floor(-1.23e167)', math.floor(-1.23e167), -1.23e167)
 
     def testFmod(self):
         self.assertRaises(TypeError, math.fmod)
index c4aeb1922b4a14d334b7cb071afe91a51ce0a9b5..361a475ca438b2293b2b6cb6c005d5657d4c9b33 100644 (file)
@@ -106,12 +106,9 @@ class PowTest(unittest.TestCase):
         # platform pow() was buggy, and Python didn't worm around it.
         eq = self.assertEquals
         a = -1.0
-        # XXX Temporary diagnostic for failure on alpha Debian buildbot
-        from sys import __stdout__
-        from math import floor
-        print >> __stdout__, "*** Number: %r" % 1.23e167
-        print >> __stdout__, "*** Floor: %r" % floor(1.23e167)
-        # XXX End diagnostic message
+        # The next two tests can still fail if the platform floor()
+        # function doesn't treat all large inputs as integers
+        # test_math should also fail if that is happening
         eq(pow(a, 1.23e167), 1.0)
         eq(pow(a, -1.23e167), 1.0)
         for b in range(-10, 11):