Issue #2335: Backport set literals syntax from Python 3.x.
diff --git a/Lib/test/test_compiler.py b/Lib/test/test_compiler.py
index 24930f8..8d4a3a99 100644
--- a/Lib/test/test_compiler.py
+++ b/Lib/test/test_compiler.py
@@ -248,6 +248,7 @@
l[3:4]
d = {'a': 2}
d = {}
+s = {1}
t = ()
t = (1, 2)
l = []
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index f144ae7..4713d1a 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -749,7 +749,7 @@
def testAtoms(self):
### atom: '(' [testlist] ')' | '[' [testlist] ']' | '{' [dictmaker] '}' | '`' testlist '`' | NAME | NUMBER | STRING
- ### dictmaker: test ':' test (',' test ':' test)* [',']
+ ### dictorsetmaker: (test ':' test (',' test ':' test)* [',']) | (test (',' test)* [','])
x = (1)
x = (1 or 2 or 3)
@@ -769,6 +769,11 @@
x = {'one': 1, 'two': 2,}
x = {'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5, 'six': 6}
+ x = {'one'}
+ x = {'one', 1,}
+ x = {'one', 'two', 'three'}
+ x = {2, 3, 4,}
+
x = `x`
x = `1 or 2 or 3`
self.assertEqual(`1,2`, '(1, 2)')
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py
index a7f8fc2..03803d9 100644
--- a/Lib/test/test_parser.py
+++ b/Lib/test/test_parser.py
@@ -59,7 +59,20 @@
def test_expressions(self):
self.check_expr("foo(1)")
+ self.check_expr("{1:1}")
+ self.check_expr("{1:1, 2:2, 3:3}")
+ self.check_expr("{1:1, 2:2, 3:3,}")
+ self.check_expr("{1}")
+ self.check_expr("{1, 2, 3}")
+ self.check_expr("{1, 2, 3,}")
+ self.check_expr("[]")
+ self.check_expr("[1]")
self.check_expr("[1, 2, 3]")
+ self.check_expr("[1, 2, 3,]")
+ self.check_expr("()")
+ self.check_expr("(1,)")
+ self.check_expr("(1, 2, 3)")
+ self.check_expr("(1, 2, 3,)")
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]")