mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	Add explicit test for a misbehaving math.floor
This commit is contained in:
		
							parent
							
								
									c473149a5a
								
							
						
					
					
						commit
						00f2029cd5
					
				
					 2 changed files with 7 additions and 6 deletions
				
			
		| 
						 | 
					@ -92,6 +92,10 @@ def testFloor(self):
 | 
				
			||||||
        self.ftest('floor(-0.5)', math.floor(-0.5), -1)
 | 
					        self.ftest('floor(-0.5)', math.floor(-0.5), -1)
 | 
				
			||||||
        self.ftest('floor(-1.0)', math.floor(-1.0), -1)
 | 
					        self.ftest('floor(-1.0)', math.floor(-1.0), -1)
 | 
				
			||||||
        self.ftest('floor(-1.5)', math.floor(-1.5), -2)
 | 
					        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):
 | 
					    def testFmod(self):
 | 
				
			||||||
        self.assertRaises(TypeError, math.fmod)
 | 
					        self.assertRaises(TypeError, math.fmod)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -106,12 +106,9 @@ def test_bug705231(self):
 | 
				
			||||||
        # platform pow() was buggy, and Python didn't worm around it.
 | 
					        # platform pow() was buggy, and Python didn't worm around it.
 | 
				
			||||||
        eq = self.assertEquals
 | 
					        eq = self.assertEquals
 | 
				
			||||||
        a = -1.0
 | 
					        a = -1.0
 | 
				
			||||||
        # XXX Temporary diagnostic for failure on alpha Debian buildbot
 | 
					        # The next two tests can still fail if the platform floor()
 | 
				
			||||||
        from sys import __stdout__
 | 
					        # function doesn't treat all large inputs as integers
 | 
				
			||||||
        from math import floor
 | 
					        # test_math should also fail if that is happening
 | 
				
			||||||
        print >> __stdout__, "*** Number: %r" % 1.23e167
 | 
					 | 
				
			||||||
        print >> __stdout__, "*** Floor: %r" % floor(1.23e167)
 | 
					 | 
				
			||||||
        # XXX End diagnostic message
 | 
					 | 
				
			||||||
        eq(pow(a, 1.23e167), 1.0)
 | 
					        eq(pow(a, 1.23e167), 1.0)
 | 
				
			||||||
        eq(pow(a, -1.23e167), 1.0)
 | 
					        eq(pow(a, -1.23e167), 1.0)
 | 
				
			||||||
        for b in range(-10, 11):
 | 
					        for b in range(-10, 11):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue