More unparse.py fixes:

- parenthesize lambdas, to avoid turning (lambda : int)() into lambda: int()
 - unparse an infinite float literals in the AST as an overflowing finite value

unparse.py now successfully round-trips on all valid Lib/*.py and Lib/test/*.py files.
This commit is contained in:
Mark Dickinson 2010-06-29 10:01:48 +00:00
parent 3eb0290346
commit 8042e28192
2 changed files with 26 additions and 11 deletions

View file

@ -87,6 +87,13 @@ class UnparseTestCase(unittest.TestCase):
def test_integer_parens(self):
self.check_roundtrip("3 .__abs__()")
def test_huge_float(self):
self.check_roundtrip("1e1000")
self.check_roundtrip("-1e1000")
def test_lambda_parentheses(self):
self.check_roundtrip("(lambda: int)()")
def test_chained_comparisons(self):
self.check_roundtrip("1 < 4 <= 5")
self.check_roundtrip("a is b is c is not d")