summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBatuhan Taşkaya <batuhanosmantaskaya@gmail.com>2020-04-13 22:51:31 (GMT)
committerGitHub <noreply@github.com>2020-04-13 22:51:31 (GMT)
commit258f5179f9494189e6a80311c86981d2a88ba9d6 (patch)
tree7eca99369a118d72ea92b04b9e24e9789e7c5fef /Lib
parent4c3da783cffb8471303fbae3e09f3d67b31c3d06 (diff)
downloadcpython-258f5179f9494189e6a80311c86981d2a88ba9d6.zip
cpython-258f5179f9494189e6a80311c86981d2a88ba9d6.tar.gz
cpython-258f5179f9494189e6a80311c86981d2a88ba9d6.tar.bz2
bpo-32894: Support unparsing of infinity numbers in ast_unparser.c (GH-17426)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_future.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_future.py b/Lib/test/test_future.py
index 9b88e3f..ebeb833 100644
--- a/Lib/test/test_future.py
+++ b/Lib/test/test_future.py
@@ -5,6 +5,7 @@ from test import support
from textwrap import dedent
import os
import re
+import sys
rx = re.compile(r'\((\S+).py, line (\d+)')
@@ -308,5 +309,18 @@ class AnnotationsFutureTestCase(unittest.TestCase):
self.assertAnnotationEqual("f'{x=!a}'", expected="f'x={x!a}'")
self.assertAnnotationEqual("f'{x=!s:*^20}'", expected="f'x={x!s:*^20}'")
+ def test_infinity_numbers(self):
+ inf = "1e" + repr(sys.float_info.max_10_exp + 1)
+ infj = f"{inf}j"
+ self.assertAnnotationEqual("1e1000", expected=inf)
+ self.assertAnnotationEqual("1e1000j", expected=infj)
+ self.assertAnnotationEqual("-1e1000", expected=f"-{inf}")
+ self.assertAnnotationEqual("3+1e1000j", expected=f"3 + {infj}")
+ self.assertAnnotationEqual("(1e1000, 1e1000j)", expected=f"({inf}, {infj})")
+ self.assertAnnotationEqual("'inf'")
+ self.assertAnnotationEqual("('inf', 1e1000, 'infxxx', 1e1000j)", expected=f"('inf', {inf}, 'infxxx', {infj})")
+ self.assertAnnotationEqual("(1e1000, (1e1000j,))", expected=f"({inf}, ({infj},))")
+
+
if __name__ == "__main__":
unittest.main()