diff options
author | Mark Dickinson <mdickinson@enthought.com> | 2012-05-07 15:34:34 (GMT) |
---|---|---|
committer | Mark Dickinson <mdickinson@enthought.com> | 2012-05-07 15:34:34 (GMT) |
commit | 11c1dee183a39626a904f3f9e09b47dab3fd8117 (patch) | |
tree | c6e6fb5ba8ba5e13d475a46f72fe3ba7066c36ab /Lib | |
parent | cf360b92099d3ebcd31f637e45df501f393ff0b0 (diff) | |
download | cpython-11c1dee183a39626a904f3f9e09b47dab3fd8117.zip cpython-11c1dee183a39626a904f3f9e09b47dab3fd8117.tar.gz cpython-11c1dee183a39626a904f3f9e09b47dab3fd8117.tar.bz2 |
Issue #14697: Fix missing parser module support for set displays and set comprehensions.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_parser.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py index edd1a09..50dc8d1 100644 --- a/Lib/test/test_parser.py +++ b/Lib/test/test_parser.py @@ -305,6 +305,29 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase): "except Exception as e:\n" " raise ValueError from e\n") + def test_set_displays(self): + self.check_expr('{2}') + self.check_expr('{2,}') + self.check_expr('{2, 3}') + self.check_expr('{2, 3,}') + + def test_dict_displays(self): + self.check_expr('{}') + self.check_expr('{a:b}') + self.check_expr('{a:b,}') + self.check_expr('{a:b, c:d}') + self.check_expr('{a:b, c:d,}') + + def test_set_comprehensions(self): + self.check_expr('{x for x in seq}') + self.check_expr('{f(x) for x in seq}') + self.check_expr('{f(x) for x in seq if condition(x)}') + + def test_dict_comprehensions(self): + self.check_expr('{x:x for x in seq}') + self.check_expr('{x**2:x[3] for x in seq if condition(x)}') + self.check_expr('{x:x for x in seq1 for y in seq2 if condition(x, y)}') + # # Second, we take *invalid* trees and make sure we get ParserError |