diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-01-25 20:12:27 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-01-25 20:12:27 (GMT) |
commit | 619eea6821a0c749d2f86d247fa3f7d28d867681 (patch) | |
tree | d49ec0caaf60c9a84e2319d48669d4588fcf6454 /Lib | |
parent | 4588c78fafd569deb21b1a721a8507636a507837 (diff) | |
download | cpython-619eea6821a0c749d2f86d247fa3f7d28d867681.zip cpython-619eea6821a0c749d2f86d247fa3f7d28d867681.tar.gz cpython-619eea6821a0c749d2f86d247fa3f7d28d867681.tar.bz2 |
PEP 227 implementation
test_new: new.code() noew takes two more arguments
test_grammer: Add a bunch of test cases for lambda (not really PEP 227 related)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/output/test_grammar | 2 | ||||
-rw-r--r-- | Lib/test/test_grammar.py | 14 | ||||
-rw-r--r-- | Lib/test/test_new.py | 3 |
3 files changed, 18 insertions, 1 deletions
diff --git a/Lib/test/output/test_grammar b/Lib/test/output/test_grammar index bc9c9d4..b75c22f 100644 --- a/Lib/test/output/test_grammar +++ b/Lib/test/output/test_grammar @@ -13,6 +13,8 @@ file_input expr_input eval_input funcdef +lambdef +SyntaxError expected for "lambda x: x = 2" simple_stmt expr_stmt print_stmt diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py index a8d26dc..8030e69 100644 --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -246,6 +246,20 @@ d22v(*(1, 2, 3, 4)) d22v(1, 2, *(3, 4, 5)) d22v(1, *(2, 3), **{'d': 4}) +### lambdef: 'lambda' [varargslist] ':' test +print 'lambdef' +l1 = lambda : 0 +verify(l1() == 0) +l2 = lambda : a[d] # XXX just testing the expression +l3 = lambda : [2 < x for x in [-1, 3, 0L]] +verify(l3() == [0, 1, 0]) +l4 = lambda x = lambda y = lambda z=1 : z : y() : x() +verify(l4() == 1) +l5 = lambda x, y, z=2: x + y + z +verify(l5(1, 2) == 5) +verify(l5(1, 2, 3) == 6) +check_syntax("lambda x: x = 2") + ### stmt: simple_stmt | compound_stmt # Tested below diff --git a/Lib/test/test_new.py b/Lib/test/test_new.py index 70ea38b..af26f01 100644 --- a/Lib/test/test_new.py +++ b/Lib/test/test_new.py @@ -58,6 +58,7 @@ if g['c'] != 3: # bogus test of new.code() print 'new.code()' -d = new.code(3, 3, 3, 3, codestr, (), (), (), "<string>", "<name>", 1, "") +d = new.code(3, 3, 3, 3, codestr, (), (), (), (), (), + "<string>", "<name>", 1, "") if verbose: print d |