Continue rolling back pep-3141 changes that changed behavior from 2.5. This

round included:
 * Revert round to its 2.6 behavior (half away from 0).
 * Because round, floor, and ceil always return float again, it's no
   longer necessary to have them delegate to __xxx___, so I've ripped
   that out of their implementations and the Real ABC. This also helps
   in implementing types that work in both 2.6 and 3.0: you return int
   from the __xxx__ methods, and let it get enabled by the version
   upgrade.
 * Make pow(-1, .5) raise a ValueError again.
This commit is contained in:
Jeffrey Yasskin 2008-01-05 08:47:13 +00:00
parent f7476c4d46
commit 9871d8fe22
13 changed files with 75 additions and 252 deletions

View file

@ -63,8 +63,8 @@ class MathTests(unittest.TestCase):
self.ftest('ceil(-1.5)', math.ceil(-1.5), -1)
class TestCeil(object):
def __ceil__(self):
return 42
def __float__(self):
return 41.3
class TestNoCeil(object):
pass
self.ftest('ceil(TestCeil())', math.ceil(TestCeil()), 42)
@ -123,8 +123,8 @@ class MathTests(unittest.TestCase):
self.ftest('floor(-1.23e167)', math.floor(-1.23e167), -1.23e167)
class TestFloor(object):
def __floor__(self):
return 42
def __float__(self):
return 42.3
class TestNoFloor(object):
pass
self.ftest('floor(TestFloor())', math.floor(TestFloor()), 42)