summaryrefslogtreecommitdiff
path: root/Lib/test/test_float.py
diff options
context:
space:
mode:
authorMark Dickinson <mdickinson@enthought.com>2012-04-29 15:31:56 +0100
committerMark Dickinson <mdickinson@enthought.com>2012-04-29 15:31:56 +0100
commite383e82e0484aed79f2c78516e3f223345408d4b (patch)
tree665c6b5274695e846f6b66fa88d673eccd0bc402 /Lib/test/test_float.py
parentd68ac85e9afd3d7e5dfc8fe2e2853d3371cc08d2 (diff)
downloadcpython-git-e383e82e0484aed79f2c78516e3f223345408d4b.tar.gz
Issue #14521: Make result of float('nan') and float('-nan') more consistent across platforms. Further, don't rely on Py_HUGE_VAL for float('inf').
Diffstat (limited to 'Lib/test/test_float.py')
-rw-r--r--Lib/test/test_float.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py
index dc0c2912be..3cee3836a3 100644
--- a/Lib/test/test_float.py
+++ b/Lib/test/test_float.py
@@ -870,6 +870,19 @@ class InfNanTest(unittest.TestCase):
self.assertFalse(NAN.is_inf())
self.assertFalse((0.).is_inf())
+ def test_inf_signs(self):
+ self.assertEqual(copysign(1.0, float('inf')), 1.0)
+ self.assertEqual(copysign(1.0, float('-inf')), -1.0)
+
+ @unittest.skipUnless(getattr(sys, 'float_repr_style', '') == 'short',
+ "applies only when using short float repr style")
+ def test_nan_signs(self):
+ # When using the dtoa.c code, the sign of float('nan') should
+ # be predictable.
+ self.assertEqual(copysign(1.0, float('nan')), 1.0)
+ self.assertEqual(copysign(1.0, float('-nan')), -1.0)
+
+
fromHex = float.fromhex
toHex = float.hex
class HexFloatTestCase(unittest.TestCase):