cython
1# ticket: t589
2
3cimport cython
4
5_set = set # CPython may not define it (in Py2.3), but Cython does :)
6
7
8def test_set_clear_bound():
9"""
10>>> type(test_set_clear_bound()) is _set
11True
12>>> list(test_set_clear_bound())
13[]
14"""
15cdef set s1 = set([1])
16clear = s1.clear
17clear()
18return s1
19
20text = u'ab jd sdflk as sa sadas asdas fsdf '
21pipe_sep = u'|'
22
23
24@cython.test_assert_path_exists(
25"//PythonCapiCallNode",
26)
27def test_unicode_join_bound(unicode sep, l):
28"""
29>>> l = text.split()
30>>> len(l)
318
32>>> print( pipe_sep.join(l) )
33ab|jd|sdflk|as|sa|sadas|asdas|fsdf
34>>> print( test_unicode_join_bound(pipe_sep, l) )
35ab|jd|sdflk|as|sa|sadas|asdas|fsdf
36"""
37join = sep.join
38return join(l)
39
40
41def test_unicode_join_bound_no_assignment(unicode sep):
42"""
43>>> test_unicode_join_bound_no_assignment(text)
44"""
45sep.join
46
47
48def test_dict_items_bound_no_assignment(dict d):
49"""
50>>> test_dict_items_bound_no_assignment({1:2})
51"""
52d.items
53
54
55def list_pop(list l):
56"""
57>>> list_pop([1,2,3])
58(2, [1, 3])
59"""
60pop = l.pop
61r = pop(1)
62return r, l
63
64
65def list_pop_literal():
66"""
67>>> list_pop_literal()
68(2, [1, 3])
69"""
70l = [1,2,3]
71pop = l.pop
72r = pop(1)
73return r, l
74
75
76def list_pop_reassign():
77"""
78>>> list_pop_reassign()
792
80"""
81l = [1,2,3]
82pop = l.pop
83l = None
84r = pop(1)
85return r
86
87
88def list_insert(list l):
89"""
90>>> list_insert([1,2,3])
91(None, [1, 4, 2, 3])
92"""
93insert = l.insert
94r = insert(1, 4)
95return r, l
96
97
98def list_insert_literal():
99"""
100>>> list_insert_literal()
101(None, [1, 4, 2, 3])
102"""
103l = [1,2,3]
104insert = l.insert
105r = insert(1, 4)
106return r, l
107
108
109def list_insert_reassign():
110"""
111>>> list_insert_reassign()
112(None, [1, 4, 2, 3])
113"""
114l = [1,2,3]
115insert = l.insert
116m, l = l, None
117r = insert(1, 4)
118return r, m
119