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

Method test_repeat_1_simple

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

Source from the content-addressed store, hash-verified

325 )
326
327 def test_repeat_1_simple(self) -> None:
328 grammar = """
329 start: thing thing+ NEWLINE
330 thing: NUMBER
331 """
332 parser_class = make_parser(grammar)
333 node = parse_string("1 2 3\n", parser_class)
334 self.assertEqual(
335 node,
336 [
337 TokenInfo(NUMBER, string="1", start=(1, 0), end=(1, 1), line="1 2 3\n"),
338 [
339 TokenInfo(
340 NUMBER, string="2", start=(1, 2), end=(1, 3), line="1 2 3\n"
341 ),
342 TokenInfo(
343 NUMBER, string="3", start=(1, 4), end=(1, 5), line="1 2 3\n"
344 ),
345 ],
346 TokenInfo(
347 NEWLINE, string="\n", start=(1, 5), end=(1, 6), line="1 2 3\n"
348 ),
349 ],
350 )
351 with self.assertRaises(SyntaxError):
352 parse_string("1\n", parser_class)
353
354 def test_repeat_1_complex(self) -> None:
355 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