MCPcopy Index your code
hub / github.com/python/cpython / test_repeat_1_complex

Method test_repeat_1_complex

Lib/test/test_peg_generator/test_pegen.py:354–399  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

352 parse_string("1\n", parser_class)
353
354 def test_repeat_1_complex(self) -> None:
355 grammar = """
356 start: term ('+' term)+ NEWLINE
357 term: NUMBER
358 """
359 parser_class = make_parser(grammar)
360 node = parse_string("1 + 2 + 3\n", parser_class)
361 self.assertEqual(
362 node,
363 [
364 TokenInfo(
365 NUMBER, string="1", start=(1, 0), end=(1, 1), line="1 + 2 + 3\n"
366 ),
367 [
368 [
369 TokenInfo(
370 OP, string="+", start=(1, 2), end=(1, 3), line="1 + 2 + 3\n"
371 ),
372 TokenInfo(
373 NUMBER,
374 string="2",
375 start=(1, 4),
376 end=(1, 5),
377 line="1 + 2 + 3\n",
378 ),
379 ],
380 [
381 TokenInfo(
382 OP, string="+", start=(1, 6), end=(1, 7), line="1 + 2 + 3\n"
383 ),
384 TokenInfo(
385 NUMBER,
386 string="3",
387 start=(1, 8),
388 end=(1, 9),
389 line="1 + 2 + 3\n",
390 ),
391 ],
392 ],
393 TokenInfo(
394 NEWLINE, string="\n", start=(1, 9), end=(1, 10), line="1 + 2 + 3\n"
395 ),
396 ],
397 )
398 with self.assertRaises(SyntaxError):
399 parse_string("1\n", parser_class)
400
401 def test_repeat_with_sep_simple(self) -> None:
402 grammar = """

Callers

nothing calls this directly

Calls 5

make_parserFunction · 0.90
parse_stringFunction · 0.90
TokenInfoClass · 0.90
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected