diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2024-10-29 23:40:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-29 23:40:12 (GMT) |
commit | 9dfef4e5f4ac3c1ce494c48f2476a694c12d72a5 (patch) | |
tree | 16baaf8027be098e70bf13ed93ffffc68c84ead7 /Lib/test | |
parent | 0e45b1fd0ffbb165f580ecdfd5234c1d54389501 (diff) | |
download | cpython-9dfef4e5f4ac3c1ce494c48f2476a694c12d72a5.zip cpython-9dfef4e5f4ac3c1ce494c48f2476a694c12d72a5.tar.gz cpython-9dfef4e5f4ac3c1ce494c48f2476a694c12d72a5.tar.bz2 |
gh-125588: Teach the python PEG generator the new f-string tokens (#125589)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_peg_generator/test_pegen.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_peg_generator/test_pegen.py b/Lib/test/test_peg_generator/test_pegen.py index 54c9dce..d860652 100644 --- a/Lib/test/test_peg_generator/test_pegen.py +++ b/Lib/test/test_peg_generator/test_pegen.py @@ -506,6 +506,14 @@ class TestPegen(unittest.TestCase): val = eval(code) self.assertEqual(val, 3.0) + def test_f_string_in_action(self) -> None: + grammar = """ + start: n=NAME NEWLINE? $ { f"name -> {n.string}" } + """ + parser_class = make_parser(grammar) + node = parse_string("a", parser_class) + self.assertEqual(node.strip(), "name -> a") + def test_nullable(self) -> None: grammar_source = """ start: sign NUMBER |