diff options
author | Alex Martelli <aleaxit@gmail.com> | 2007-08-22 21:14:17 (GMT) |
---|---|---|
committer | Alex Martelli <aleaxit@gmail.com> | 2007-08-22 21:14:17 (GMT) |
commit | d8672aa8a4c925c69cac51561c68a9820cf97124 (patch) | |
tree | 8b9b8a463b69f80c2b9e38805d0686cb7e120692 /Lib/test/test_float.py | |
parent | 89e975fc74d794c2087244d6f684477b334233c3 (diff) | |
download | cpython-d8672aa8a4c925c69cac51561c68a9820cf97124.zip cpython-d8672aa8a4c925c69cac51561c68a9820cf97124.tar.gz cpython-d8672aa8a4c925c69cac51561c68a9820cf97124.tar.bz2 |
Fix compile.c so that it records 0.0 and -0.0 as separate constants in a code
object's co_consts tuple; add a test to show that the previous behavior (where
these two constants were "collapsed" into one) causes serious malfunctioning.
Diffstat (limited to 'Lib/test/test_float.py')
-rw-r--r-- | Lib/test/test_float.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py index fb47db8..1c74c96 100644 --- a/Lib/test/test_float.py +++ b/Lib/test/test_float.py @@ -81,6 +81,7 @@ class UnknownFormatTestCase(unittest.TestCase): # on an IEEE platform, all we guarantee is that bit patterns # representing infinities or NaNs do not raise an exception; all else # is accident (today). +# let's also try to guarantee that -0.0 and 0.0 don't get confused. class IEEEFormatTestCase(unittest.TestCase): if float.__getformat__("double").startswith("IEEE"): @@ -99,6 +100,20 @@ class IEEEFormatTestCase(unittest.TestCase): ('<f', LE_FLOAT_NAN)]: struct.unpack(fmt, data) + if float.__getformat__("double").startswith("IEEE"): + def test_negative_zero(self): + import math + def pos_pos(): + return 0.0, math.atan2(0.0, -1) + def pos_neg(): + return 0.0, math.atan2(-0.0, -1) + def neg_pos(): + return -0.0, math.atan2(0.0, -1) + def neg_neg(): + return -0.0, math.atan2(-0.0, -1) + self.assertEquals(pos_pos(), neg_pos()) + self.assertEquals(pos_neg(), neg_neg()) + def test_main(): test_support.run_unittest( |