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

Delta Between Two Patch Sets: Lib/test/test_parser.py

Issue 11682: PEP 380 reference implementation for 3.3
Left Patch Set: Created 8 years, 4 months ago
Right Patch Set: Created 7 years, 10 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
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") 53 self.check_suite("def f(): yield from 1")
54 self.check_suite("def f(): x = yield from 1") 54 self.check_suite("def f(): x = yield from 1")
55 self.check_suite("def f(): f(yield from 1)") 55 self.check_suite("def f(): f((yield from 1))")
56 self.check_suite("def f(): yield 1; return 1") 56 self.check_suite("def f(): yield 1; return 1")
57 self.check_suite("def f():\n" 57 self.check_suite("def f():\n"
58 " for x in range(30):\n" 58 " for x in range(30):\n"
59 " yield x\n") 59 " yield x\n")
60 self.check_suite("def f():\n" 60 self.check_suite("def f():\n"
61 " if (yield):\n" 61 " if (yield):\n"
62 " yield x\n") 62 " yield x\n")
63 63
64 def test_expressions(self): 64 def test_expressions(self):
65 self.check_expr("foo(1)") 65 self.check_expr("foo(1)")
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 618
619 # 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
620 620
621 class OtherParserCase(unittest.TestCase): 621 class OtherParserCase(unittest.TestCase):
622 622
623 def test_two_args_to_expr(self): 623 def test_two_args_to_expr(self):
624 # See bug #12264 624 # See bug #12264
625 with self.assertRaises(TypeError): 625 with self.assertRaises(TypeError):
626 parser.expr("a", "b") 626 parser.expr("a", "b")
627 627
628
629 def test_main(): 628 def test_main():
630 support.run_unittest( 629 support.run_unittest(
631 RoundtripLegalSyntaxTestCase, 630 RoundtripLegalSyntaxTestCase,
632 IllegalSyntaxTestCase, 631 IllegalSyntaxTestCase,
633 CompileTestCase, 632 CompileTestCase,
634 ParserStackLimitTestCase, 633 ParserStackLimitTestCase,
635 STObjectTestCase, 634 STObjectTestCase,
636 OtherParserCase, 635 OtherParserCase,
637 ) 636 )
638 637
639 638
640 if __name__ == "__main__": 639 if __name__ == "__main__":
641 test_main() 640 test_main()
LEFTRIGHT

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