Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(4370)

Side by Side Diff: Lib/test/test_parser.py

Issue 11682: PEP 380 reference implementation for 3.3
Patch Set: Created 7 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 import parser 1 import parser
2 import unittest 2 import unittest
3 import sys 3 import sys
4 import operator 4 import operator
5 from test import support 5 from test import support
6 6
7 # 7 #
8 # First, we test that we can generate trees from valid source fragments, 8 # First, we test that we can generate trees from valid source fragments,
9 # and that these valid trees are indeed allowed by the tree-loading side 9 # and that these valid trees are indeed allowed by the tree-loading side
10 # of the parser module. 10 # of the parser module.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 self.check_suite("def f(): yield") 43 self.check_suite("def f(): yield")
44 self.check_suite("def f(): x += yield") 44 self.check_suite("def f(): x += yield")
45 self.check_suite("def f(): x = yield 1") 45 self.check_suite("def f(): x = yield 1")
46 self.check_suite("def f(): x = y = yield 1") 46 self.check_suite("def f(): x = y = yield 1")
47 self.check_suite("def f(): x = yield") 47 self.check_suite("def f(): x = yield")
48 self.check_suite("def f(): x = y = yield") 48 self.check_suite("def f(): x = y = yield")
49 self.check_suite("def f(): 1 + (yield)*2") 49 self.check_suite("def f(): 1 + (yield)*2")
50 self.check_suite("def f(): (yield 1)*2") 50 self.check_suite("def f(): (yield 1)*2")
51 self.check_suite("def f(): return; yield 1") 51 self.check_suite("def f(): return; yield 1")
52 self.check_suite("def f(): yield 1; return") 52 self.check_suite("def f(): yield 1; return")
53 self.check_suite("def f(): yield from 1")
54 self.check_suite("def f(): x = yield from 1")
55 self.check_suite("def f(): f((yield from 1))")
56 self.check_suite("def f(): yield 1; return 1")
53 self.check_suite("def f():\n" 57 self.check_suite("def f():\n"
54 " for x in range(30):\n" 58 " for x in range(30):\n"
55 " yield x\n") 59 " yield x\n")
56 self.check_suite("def f():\n" 60 self.check_suite("def f():\n"
57 " if (yield):\n" 61 " if (yield):\n"
58 " yield x\n") 62 " yield x\n")
59 63
60 def test_expressions(self): 64 def test_expressions(self):
61 self.check_expr("foo(1)") 65 self.check_expr("foo(1)")
62 self.check_expr("[1, 2, 3]") 66 self.check_expr("[1, 2, 3]")
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 617
614 618
615 # XXX tests for pickling and unpickling of ST objects should go here 619 # XXX tests for pickling and unpickling of ST objects should go here
616 620
617 class OtherParserCase(unittest.TestCase): 621 class OtherParserCase(unittest.TestCase):
618 622
619 def test_two_args_to_expr(self): 623 def test_two_args_to_expr(self):
620 # See bug #12264 624 # See bug #12264
621 with self.assertRaises(TypeError): 625 with self.assertRaises(TypeError):
622 parser.expr("a", "b") 626 parser.expr("a", "b")
623
624 627
625 def test_main(): 628 def test_main():
626 support.run_unittest( 629 support.run_unittest(
627 RoundtripLegalSyntaxTestCase, 630 RoundtripLegalSyntaxTestCase,
628 IllegalSyntaxTestCase, 631 IllegalSyntaxTestCase,
629 CompileTestCase, 632 CompileTestCase,
630 ParserStackLimitTestCase, 633 ParserStackLimitTestCase,
631 STObjectTestCase, 634 STObjectTestCase,
632 OtherParserCase, 635 OtherParserCase,
633 ) 636 )
634 637
635 638
636 if __name__ == "__main__": 639 if __name__ == "__main__":
637 test_main() 640 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_grammar.py ('k') | Lib/test/test_pep380.py » ('j') | Modules/parsermodule.c » ('J')

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+