1# ticket: 589 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 11 True 12 >>> list(test_set_clear_bound()) 13 [] 14 """ 15 cdef set s1 = set([1]) 16 clear = s1.clear 17 clear() 18 return 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) 31 8 32 >>> print( pipe_sep.join(l) ) 33 ab|jd|sdflk|as|sa|sadas|asdas|fsdf 34 >>> print( test_unicode_join_bound(pipe_sep, l) ) 35 ab|jd|sdflk|as|sa|sadas|asdas|fsdf 36 """ 37 join = sep.join 38 return join(l) 39 40 41def test_unicode_join_bound_no_assignment(unicode sep): 42 """ 43 >>> test_unicode_join_bound_no_assignment(text) 44 """ 45 sep.join 46 47 48def test_dict_items_bound_no_assignment(dict d): 49 """ 50 >>> test_dict_items_bound_no_assignment({1:2}) 51 """ 52 d.items 53 54 55def list_pop(list l): 56 """ 57 >>> list_pop([1,2,3]) 58 (2, [1, 3]) 59 """ 60 pop = l.pop 61 r = pop(1) 62 return r, l 63 64 65def list_pop_literal(): 66 """ 67 >>> list_pop_literal() 68 (2, [1, 3]) 69 """ 70 l = [1,2,3] 71 pop = l.pop 72 r = pop(1) 73 return r, l 74 75 76def list_pop_reassign(): 77 """ 78 >>> list_pop_reassign() 79 2 80 """ 81 l = [1,2,3] 82 pop = l.pop 83 l = None 84 r = pop(1) 85 return r 86 87 88def list_insert(list l): 89 """ 90 >>> list_insert([1,2,3]) 91 (None, [1, 4, 2, 3]) 92 """ 93 insert = l.insert 94 r = insert(1, 4) 95 return r, l 96 97 98def list_insert_literal(): 99 """ 100 >>> list_insert_literal() 101 (None, [1, 4, 2, 3]) 102 """ 103 l = [1,2,3] 104 insert = l.insert 105 r = insert(1, 4) 106 return r, l 107 108 109def list_insert_reassign(): 110 """ 111 >>> list_insert_reassign() 112 (None, [1, 4, 2, 3]) 113 """ 114 l = [1,2,3] 115 insert = l.insert 116 m, l = l, None 117 r = insert(1, 4) 118 return r, m 119