summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-12-04 13:04:18 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2010-12-04 13:04:18 (GMT)
commit0169af153477cdade23a4197fff117d7a6298b8e (patch)
treecf7f561192a39535c481aaa09ec822b9e354e6cc /Lib
parent33154388f9f6b202fd513a98270a4607f20b47c0 (diff)
downloadcpython-0169af153477cdade23a4197fff117d7a6298b8e.zip
cpython-0169af153477cdade23a4197fff117d7a6298b8e.tar.gz
cpython-0169af153477cdade23a4197fff117d7a6298b8e.tar.bz2
Merged revisions 87032 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r87032 | mark.dickinson | 2010-12-04 12:25:30 +0000 (Sat, 04 Dec 2010) | 3 lines Issue #10596: Fix float.__mod__ to have the same behaviour as float.__divmod__ with respect to signed zeros. ........
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_float.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py
index b4897c9..b5b6b65 100644
--- a/Lib/test/test_float.py
+++ b/Lib/test/test_float.py
@@ -240,6 +240,31 @@ class GeneralFloatCases(unittest.TestCase):
self.assertTrue(s == s, "{%r} not equal to itself" % f)
self.assertTrue(d == d, "{%r : None} not equal to itself" % f)
+ def assertEqualAndEqualSign(self, a, b):
+ # fail unless a == b and a and b have the same sign bit;
+ # the only difference from assertEqual is that this test
+ # distingishes -0.0 and 0.0.
+ self.assertEqual((a, copysign(1.0, a)), (b, copysign(1.0, b)))
+
+ @requires_IEEE_754
+ def test_float_mod(self):
+ # Check behaviour of % operator for IEEE 754 special cases.
+ # In particular, check signs of zeros.
+ mod = operator.mod
+
+ self.assertEqualAndEqualSign(mod(-1.0, 1.0), 0.0)
+ self.assertEqualAndEqualSign(mod(-1e-100, 1.0), 1.0)
+ self.assertEqualAndEqualSign(mod(-0.0, 1.0), 0.0)
+ self.assertEqualAndEqualSign(mod(0.0, 1.0), 0.0)
+ self.assertEqualAndEqualSign(mod(1e-100, 1.0), 1e-100)
+ self.assertEqualAndEqualSign(mod(1.0, 1.0), 0.0)
+
+ self.assertEqualAndEqualSign(mod(-1.0, -1.0), -0.0)
+ self.assertEqualAndEqualSign(mod(-1e-100, -1.0), -1e-100)
+ self.assertEqualAndEqualSign(mod(-0.0, -1.0), -0.0)
+ self.assertEqualAndEqualSign(mod(0.0, -1.0), -0.0)
+ self.assertEqualAndEqualSign(mod(1e-100, -1.0), -1.0)
+ self.assertEqualAndEqualSign(mod(1.0, -1.0), -0.0)
class FormatFunctionsTestCase(unittest.TestCase):