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

Delta Between Two Patch Sets: Lib/lib2to3/tests/data/py3_test_grammar.py

Issue 27095: Simplify MAKE_FUNCTION
Left Patch Set: Created 3 years, 4 months ago
Right Patch Set: Created 3 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 # Python test set -- part 1, grammar. 1 # Python test set -- part 1, grammar.
2 # This just tests whether the parser accepts them all. 2 # This just tests whether the parser accepts them all.
3 3
4 # NOTE: When you run this test as a script from the command line, you 4 # NOTE: When you run this test as a script from the command line, you
5 # get warnings about certain hex/oct constants. Since those are 5 # get warnings about certain hex/oct constants. Since those are
6 # issued by the parser, you can't suppress them by adding a 6 # issued by the parser, you can't suppress them by adding a
7 # filterwarnings() call to this module. Therefore, to shut up the 7 # filterwarnings() call to this module. Therefore, to shut up the
8 # regression test, the filterwarnings() call has been added to 8 # regression test, the filterwarnings() call has been added to
9 # regrtest.py. 9 # regrtest.py.
10 10
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 **k:11) -> 12: pass 312 **k:11) -> 12: pass
313 self.assertEquals(f.__annotations__, 313 self.assertEquals(f.__annotations__,
314 {'b': 1, 'c': 2, 'e': 3, 'g': 6, 'h': 7, 'j': 9, 314 {'b': 1, 'c': 2, 'e': 3, 'g': 6, 'h': 7, 'j': 9,
315 'k': 11, 'return': 12}) 315 'k': 11, 'return': 12})
316 # Check for SF Bug #1697248 - mixing decorators and a return annotation 316 # Check for SF Bug #1697248 - mixing decorators and a return annotation
317 def null(x): return x 317 def null(x): return x
318 @null 318 @null
319 def f(x) -> list: pass 319 def f(x) -> list: pass
320 self.assertEquals(f.__annotations__, {'return': list}) 320 self.assertEquals(f.__annotations__, {'return': list})
321 321
322 # test MAKE_FUNCTION with a variety of oparg's 322 # test closures with a variety of oparg's
storchaka 2016/05/27 22:13:11 Tests above also test MAKE_FUNCTION.
323 closure = 1 323 closure = 1
324 def f(): return closure 324 def f(): return closure
325 def f(x=1): return closure 325 def f(x=1): return closure
326 def f(*, k=1): return closure 326 def f(*, k=1): return closure
327 def f() -> int: return closure 327 def f() -> int: return closure
328 328
329 # Check ast errors in *args and *kwargs 329 # Check ast errors in *args and *kwargs
330 check_syntax_error(self, "f(*g(1=2))") 330 check_syntax_error(self, "f(*g(1=2))")
331 check_syntax_error(self, "f(**g(1=2))") 331 check_syntax_error(self, "f(**g(1=2))")
332 332
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 self.assertEqual((6 * 2 if 1 else 4), 12) 914 self.assertEqual((6 * 2 if 1 else 4), 12)
915 self.assertEqual((6 / 2 if 1 else 3), 3) 915 self.assertEqual((6 / 2 if 1 else 3), 3)
916 self.assertEqual((6 < 4 if 0 else 2), 2) 916 self.assertEqual((6 < 4 if 0 else 2), 2)
917 917
918 918
919 def test_main(): 919 def test_main():
920 run_unittest(TokenTests, GrammarTests) 920 run_unittest(TokenTests, GrammarTests)
921 921
922 if __name__ == '__main__': 922 if __name__ == '__main__':
923 test_main() 923 test_main()
LEFTRIGHT

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