mirror of
https://github.com/python/cpython.git
synced 2025-09-08 01:41:19 +00:00
bpo-32894: Support unparsing of infinity numbers in ast_unparser.c (GH-17426)
This commit is contained in:
parent
4c3da783cf
commit
258f5179f9
3 changed files with 68 additions and 5 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue