summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-05-11 15:33:08 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-05-11 15:33:08 (GMT)
commitb1d45856c255e480c7365e02fc91511c1438ac2a (patch)
tree5488ecd3cf23f21ded663d308ca5eec5a16f93c2 /Lib
parent68e27eb8347978914641ca9c0e971ae1817e5257 (diff)
downloadcpython-b1d45856c255e480c7365e02fc91511c1438ac2a.zip
cpython-b1d45856c255e480c7365e02fc91511c1438ac2a.tar.gz
cpython-b1d45856c255e480c7365e02fc91511c1438ac2a.tar.bz2
Issue #5981: Fix some float.fromhex bugs related to inf and nan handling.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_float.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py
index 1c6c412..345a815 100644
--- a/Lib/test/test_float.py
+++ b/Lib/test/test_float.py
@@ -462,6 +462,11 @@ class HexFloatTestCase(unittest.TestCase):
'snan',
'NaNs',
'nna',
+ 'an',
+ 'nf',
+ 'nfinity',
+ 'inity',
+ 'iinity',
'0xnan',
'',
' ',
@@ -510,6 +515,32 @@ class HexFloatTestCase(unittest.TestCase):
'got %r instead' % (x, result))
+ def test_whitespace(self):
+ value_pairs = [
+ ('inf', INF),
+ ('-Infinity', -INF),
+ ('nan', NAN),
+ ('1.0', 1.0),
+ ('-0x.2', -0.125),
+ ('-0.0', -0.0)
+ ]
+ whitespace = [
+ '',
+ ' ',
+ '\t',
+ '\n',
+ '\n \t',
+ '\f',
+ '\v',
+ '\r'
+ ]
+ for inp, expected in value_pairs:
+ for lead in whitespace:
+ for trail in whitespace:
+ got = fromHex(lead + inp + trail)
+ self.identical(got, expected)
+
+
def test_from_hex(self):
MIN = self.MIN;
MAX = self.MAX;