summaryrefslogtreecommitdiff
path: root/Lib/test/test_parser.py
diff options
context:
space:
mode:
authorAlexandre Vassalotti <alexandre@peadrop.com>2010-01-11 22:36:12 +0000
committerAlexandre Vassalotti <alexandre@peadrop.com>2010-01-11 22:36:12 +0000
commitb646547bb45fe1df6abefd94f892c633798d91d2 (patch)
treeef1add045741d309129266726f5ba45562184091 /Lib/test/test_parser.py
parent0ca7452794bef03b66f56cc996a73cac066d0ec1 (diff)
downloadcpython-git-b646547bb45fe1df6abefd94f892c633798d91d2.tar.gz
Issue #2333: Backport set and dict comprehensions syntax.
Diffstat (limited to 'Lib/test/test_parser.py')
-rw-r--r--Lib/test/test_parser.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py
index 03803d9aaf..6ae99758d3 100644
--- a/Lib/test/test_parser.py
+++ b/Lib/test/test_parser.py
@@ -76,9 +76,20 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
self.check_expr("[x**3 for x in range(20)]")
self.check_expr("[x**3 for x in range(20) if x % 3]")
self.check_expr("[x**3 for x in range(20) if x % 2 if x % 3]")
+ self.check_expr("[x+y for x in range(30) for y in range(20) if x % 2 if y % 3]")
+ #self.check_expr("[x for x in lambda: True, lambda: False if x()]")
self.check_expr("list(x**3 for x in range(20))")
self.check_expr("list(x**3 for x in range(20) if x % 3)")
self.check_expr("list(x**3 for x in range(20) if x % 2 if x % 3)")
+ self.check_expr("list(x+y for x in range(30) for y in range(20) if x % 2 if y % 3)")
+ self.check_expr("{x**3 for x in range(30)}")
+ self.check_expr("{x**3 for x in range(30) if x % 3}")
+ self.check_expr("{x**3 for x in range(30) if x % 2 if x % 3}")
+ self.check_expr("{x+y for x in range(30) for y in range(20) if x % 2 if y % 3}")
+ self.check_expr("{x**3: y**2 for x, y in zip(range(30), range(30))}")
+ self.check_expr("{x**3: y**2 for x, y in zip(range(30), range(30)) if x % 3}")
+ self.check_expr("{x**3: y**2 for x, y in zip(range(30), range(30)) if x % 3 if y % 3}")
+ self.check_expr("{x:y for x in range(30) for y in range(20) if x % 2 if y % 3}")
self.check_expr("foo(*args)")
self.check_expr("foo(*args, **kw)")
self.check_expr("foo(**kw)")
@@ -107,6 +118,7 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
self.check_expr("lambda foo=bar, blaz=blat+2, **z: 0")
self.check_expr("lambda foo=bar, blaz=blat+2, *y, **z: 0")
self.check_expr("lambda x, *y, **z: 0")
+ self.check_expr("lambda x: 5 if x else 2")
self.check_expr("(x for x in range(10))")
self.check_expr("foo(x for x in range(10))")