[Python-checkins] CVS: python/dist/src/Lib/test test_grammar.py,1.30,1.31 test_scope.py,1.4,1.5
Jeremy Hylton
jhylton@users.sourceforge.net
Fri, 09 Feb 2001 14:56:48 -0800
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv16963/test
Modified Files:
test_grammar.py test_scope.py
Log Message:
update test cases for recent compiler changes: exec/import * in nested
functinos and cell vars with */** parameters
Index: test_grammar.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_grammar.py,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -r1.30 -r1.31
*** test_grammar.py 2001/02/09 20:17:14 1.30
--- test_grammar.py 2001/02/09 22:56:46 1.31
***************
*** 387,391 ****
from sys import *
from sys import path, argv
- check_syntax("def f(): from sys import *")
print 'global_stmt' # 'global' NAME (',' NAME)*
--- 387,390 ----
Index: test_scope.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_scope.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** test_scope.py 2001/02/09 20:17:14 1.4
--- test_scope.py 2001/02/09 22:56:46 1.5
***************
*** 186,228 ****
raise TestFailed
! # XXX for now, it is easiest to call this a syntax error:
! # explicit is better than implicit...
! test1 = \
! """def unoptimized_clash1(strip):
def f(s):
from string import *
return strip(s) # ambiguity: free or local
return f
! """
! check_syntax(test1)
! # a little harder to reject this one, but possible...
! test2 = \
! """def unoptimized_clash2():
from string import *
def f(s):
return strip(s) # ambiguity: global or local
return f
! """
! # check_syntax(test2)
! # XXX could allow this for exec with const argument, but what's the point
! test3 = \
! """def error(y):
exec "a = 1"
def f(x):
return x + y
return f
! """
! check_syntax(test3)
! test4 = \
! """def f(x):
def g():
return x
! del x
! """
! check_syntax(test4)
print "12. lambdas"
--- 186,248 ----
raise TestFailed
! check_syntax("""def unoptimized_clash1(strip):
def f(s):
from string import *
return strip(s) # ambiguity: free or local
return f
! """)
! check_syntax("""def unoptimized_clash2():
from string import *
def f(s):
return strip(s) # ambiguity: global or local
return f
! """)
! check_syntax("""def unoptimized_clash2():
! from string import *
! def g():
! def f(s):
! return strip(s) # ambiguity: global or local
! return f
! """)
!
! # XXX could allow this for exec with const argument, but what's the point
! check_syntax("""def error(y):
exec "a = 1"
def f(x):
return x + y
return f
! """)
! check_syntax("""def f(x):
def g():
return x
! del x # can't del name
! """)
!
! check_syntax("""def f():
! def g():
! from string import *
! return strip # global or local?
! """)
+ # and verify a few cases that should work
+
+ def noproblem1():
+ from string import *
+ f = lambda x:x
+
+ def noproblem2():
+ from string import *
+ def f(x):
+ return x + 1
+
+ def noproblem3():
+ from string import *
+ def f(x):
+ global y
+ y = x
+
print "12. lambdas"
***************
*** 276,277 ****
--- 296,320 ----
else:
raise TestFailed
+
+ print "14. complex definitions"
+
+ def makeReturner(*lst):
+ def returner():
+ return lst
+ return returner
+
+ verify(makeReturner(1,2,3)() == (1,2,3))
+
+ def makeReturner2(**kwargs):
+ def returner():
+ return kwargs
+ return returner
+
+ verify(makeReturner2(a=11)()['a'] == 11)
+
+ def makeAddPair((a, b)):
+ def addPair((c, d)):
+ return (a + c, b + d)
+ return addPair
+
+ verify(makeAddPair((1, 2))((100, 200)) == (101,202))