diff options
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_compiler.py | 1 | ||||
-rw-r--r-- | Lib/test/test_grammar.py | 7 | ||||
-rw-r--r-- | Lib/test/test_parser.py | 13 |
3 files changed, 20 insertions, 1 deletions
diff --git a/Lib/test/test_compiler.py b/Lib/test/test_compiler.py index 24930f8a63..8d4a3a995e 100644 --- a/Lib/test/test_compiler.py +++ b/Lib/test/test_compiler.py @@ -248,6 +248,7 @@ l[0] 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 f144ae782e..4713d1ab78 100644 --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -749,7 +749,7 @@ hello world 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 @@ hello world 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 a7f8fc2f8f..03803d9aaf 100644 --- a/Lib/test/test_parser.py +++ b/Lib/test/test_parser.py @@ -59,7 +59,20 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase): 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]") |