Cython has moved to github.
cython-devel
view tests/run/exectest.pyx @ 1622:4f0327bdebc9
test for temp allocation bug in call
| author | Robert Bradshaw <robertwb@math.washington.edu> |
|---|---|
| date | Sat Jan 17 01:25:34 2009 -0800 (3 years ago) |
| parents | 1e39bd221c5d |
| children | 5ac6e2c720cd |
line source
1 __doc__ = """# no unicode string, not tested in Python3!
2 #>>> a
3 #Traceback (most recent call last):
4 #NameError: name 'a' is not defined
5 #>>> test_module_scope()
6 #>>> a
8 >>> test_dict_scope1()
9 2
11 >>> d = {}
12 >>> test_dict_scope2(d)
13 >>> print d['b']
14 2
16 >>> d1 = {}
17 >>> test_dict_scope3(d1, d1)
18 >>> print d1['b']
19 2
21 >>> d1, d2 = {}, {}
22 >>> test_dict_scope3(d1, d2)
23 >>> print d1.get('b'), d2.get('b')
24 None 2
26 >>> d1, d2 = {}, {}
27 >>> test_dict_scope3(d1, d2)
28 >>> print d1.get('b'), d2.get('b')
29 None 2
31 >>> d1, d2 = dict(a=11), dict(c=5)
32 >>> test_dict_scope_ref(d1, d2)
33 >>> print d1.get('b'), d2.get('b')
34 None 16
36 >>> d = dict(a=11, c=5)
37 >>> test_dict_scope_ref(d, d)
38 >>> print d['b']
39 16
41 >>> d = dict(seq = [1,2,3,4])
42 >>> add_iter = test_def(d, 'seq')
43 >>> list(add_iter())
44 [2, 3, 4, 5]
46 >>> # errors
48 >>> d1, d2 = {}, {}
49 >>> test_dict_scope_ref(d1, d2)
50 Traceback (most recent call last):
51 NameError: name 'a' is not defined
52 """
54 #def test_module_scope():
55 # exec "a=1+1"
56 # return __dict__['a']
58 def test_dict_scope1():
59 cdef dict d = {}
60 exec "b=1+1" in d
61 return d['b']
63 def test_dict_scope2(d):
64 exec "b=1+1" in d
66 def test_dict_scope3(d1, d2):
67 exec "b=1+1" in d1, d2
69 def test_dict_scope_ref(d1, d2):
70 exec "b=a+c" in d1, d2
72 def test_def(d, varref):
73 exec """
74 def test():
75 for x in %s:
76 yield x+1
77 """ % varref in d
78 return d['test']
