Cython has moved to github.

cython-devel

view tests/run/tupleassign.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 38d75c6cef23
children 7c9b5a80ccfe
line source
1 __doc__ = u"""
2 >>> assign3(l)
3 (1, 2, 3)
4 >>> assign3(t)
5 (1, 2, 3)
6 >>> assign3_int(l)
7 (1, 2, 3)
8 >>> assign3_mixed1(l)
9 (1, 2, 3)
10 >>> assign3_mixed2(l)
11 (1, 2, 3)
12 >>> assign3_mixed3(l)
13 (1, 2, 3)
15 >>> a,b = 99,98
16 >>> a,b = t
17 Traceback (most recent call last):
18 ValueError: too many values to unpack
19 >>> a,b
20 (99, 98)
22 >>> test_overwrite(l)
23 (99, 98)
24 >>> test_overwrite(t)
25 (99, 98)
27 >>> test_overwrite_int(l)
28 (99, 98)
29 >>> test_overwrite_int(t)
30 (99, 98)
32 >>> test_overwrite_mixed(l)
33 (99, 98)
34 >>> test_overwrite_mixed(t)
35 (99, 98)
37 >>> test_overwrite_mixed2(l)
38 (99, 98)
39 >>> test_overwrite_mixed2(t)
40 (99, 98)
41 """
43 t = (1,2,3)
44 l = [1,2,3]
46 def assign3(t):
47 a,b,c = t
48 return (a,b,c)
50 def assign3_int(t):
51 cdef int a,b,c
52 a,b,c = t
53 return (a,b,c)
55 def assign3_mixed1(t):
56 cdef int a
57 a,b,c = t
58 return (a,b,c)
60 def assign3_mixed2(t):
61 cdef int b
62 a,b,c = t
63 return (a,b,c)
65 def assign3_mixed3(t):
66 cdef int c
67 a,b,c = t
68 return (a,b,c)
70 def assign3_mixed4(t):
71 cdef int b,c
72 a,b,c = t
73 return (a,b,c)
75 def test_overwrite(t):
76 a,b = 99,98
77 try:
78 a,b = t
79 except ValueError:
80 pass
81 return (a,b)
83 def test_overwrite_int(t):
84 cdef int a,b
85 a,b = 99,98
86 try:
87 a,b = t
88 except ValueError:
89 pass
90 return (a,b)
92 def test_overwrite_mixed(t):
93 cdef int b
94 a,b = 99,98
95 try:
96 a,b = t
97 except ValueError:
98 pass
99 return (a,b)
101 def test_overwrite_mixed2(t):
102 cdef int a
103 a,b = 99,98
104 try:
105 a,b = t
106 except ValueError:
107 pass
108 return (a,b)