From: Stefan Behnel Date: Tue, 11 Nov 2008 21:39:17 +0000 (+0100) Subject: extended test case X-Git-Tag: 0.11-beta~263^2~1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=35b11d4c84febbc1e86cb552546c838424b18142;p=cython.git extended test case --- diff --git a/tests/run/exectest.pyx b/tests/run/exectest.pyx index 8e607d9b..11b36fbd 100644 --- a/tests/run/exectest.pyx +++ b/tests/run/exectest.pyx @@ -1,5 +1,7 @@ __doc__ = """# no unicode string, not tested in Python3! #>>> a +#Traceback (most recent call last): +#NameError: name 'a' is not defined #>>> test_module_scope() #>>> a @@ -35,10 +37,21 @@ None 16 >>> test_dict_scope_ref(d, d) >>> print d['b'] 16 + +>>> d = dict(seq = [1,2,3,4]) +>>> add_iter = test_def(d, 'seq') +>>> list(add_iter()) +[2, 3, 4, 5] + +>>> # errors + +>>> d1, d2 = {}, {} +>>> test_dict_scope_ref(d1, d2) +Traceback (most recent call last): +NameError: name 'a' is not defined """ #def test_module_scope(): -# global a # exec "a=1+1" # return __dict__['a'] @@ -55,3 +68,11 @@ def test_dict_scope3(d1, d2): def test_dict_scope_ref(d1, d2): exec "b=a+c" in d1, d2 + +def test_def(d, varref): + exec """ +def test(): + for x in %s: + yield x+1 +""" % varref in d + return d['test']