Mercurial > vim
annotate src/testdir/test87.in @ 5288:46cf49cc9289 v7.4b.020
updated for version 7.4b.020
Problem: "g~ap" changes first character of next paragraph. (Manuel Ortega)
Solution: Avoid subtracting (0 - 1) from todo. (Mike Williams)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Fri, 09 Aug 2013 19:48:40 +0200 |
parents | 29e57603bf6f |
children | 9cedb4dfd4c8 |
rev | line source |
---|---|
3618 | 1 Tests for various python features. vim: set ft=vim : |
2 | |
3 STARTTEST | |
4 :so small.vim | |
4851
96e154e825a7
updated for version 7.3.1172
Bram Moolenaar <bram@vim.org>
parents:
4839
diff
changeset
|
5 :set noswapfile |
3618 | 6 :if !has('python3') | e! test.ok | wq! test.out | endif |
4425 | 7 :lang C |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
8 :fun Test() |
3618 | 9 :py3 import vim |
10 :let l = [] | |
11 :py3 l=vim.bindeval('l') | |
12 :py3 f=vim.bindeval('function("strlen")') | |
13 :" Extending List directly with different types | |
14 :py3 l+=[1, "as'd", [1, 2, f, {'a': 1}]] | |
15 :$put =string(l) | |
16 :$put =string(l[-1]) | |
17 :try | |
18 : $put =string(l[-4]) | |
19 :catch | |
20 : $put =v:exception[:13] | |
21 :endtry | |
22 :" List assignment | |
23 :py3 l[0]=0 | |
24 :$put =string(l) | |
25 :py3 l[-2]=f | |
26 :$put =string(l) | |
27 :" | |
28 :" Extending Dictionary directly with different types | |
29 :let d = {} | |
4631
4157fef7b950
updated for version 7.3.1063
Bram Moolenaar <bram@vim.org>
parents:
4629
diff
changeset
|
30 :fun d.f() |
4157fef7b950
updated for version 7.3.1063
Bram Moolenaar <bram@vim.org>
parents:
4629
diff
changeset
|
31 : return 1 |
4157fef7b950
updated for version 7.3.1063
Bram Moolenaar <bram@vim.org>
parents:
4629
diff
changeset
|
32 :endfun |
4627
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
33 py3 << EOF |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
34 d=vim.bindeval('d') |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
35 d['1']='asd' |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
36 d.update(b=[1, 2, f]) |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
37 d.update((('-1', {'a': 1}),)) |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
38 d.update({'0': -1}) |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
39 dk = d.keys() |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
40 dv = d.values() |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
41 di = d.items() |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
42 dk.sort(key=repr) |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
43 dv.sort(key=repr) |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
44 di.sort(key=repr) |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
45 EOF |
4631
4157fef7b950
updated for version 7.3.1063
Bram Moolenaar <bram@vim.org>
parents:
4629
diff
changeset
|
46 :$put =py3eval('d[''f''](self={})') |
4627
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
47 :$put =py3eval('repr(dk)') |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
48 :$put =substitute(py3eval('repr(dv)'),'0x\x\+','','g') |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
49 :$put =substitute(py3eval('repr(di)'),'0x\x\+','','g') |
4631
4157fef7b950
updated for version 7.3.1063
Bram Moolenaar <bram@vim.org>
parents:
4629
diff
changeset
|
50 :for [key, Val] in sort(items(d)) |
4157fef7b950
updated for version 7.3.1063
Bram Moolenaar <bram@vim.org>
parents:
4629
diff
changeset
|
51 : $put =string(key) . ' : ' . string(Val) |
4157fef7b950
updated for version 7.3.1063
Bram Moolenaar <bram@vim.org>
parents:
4629
diff
changeset
|
52 : unlet key Val |
3618 | 53 :endfor |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
54 :py3 del dk |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
55 :py3 del di |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
56 :py3 del dv |
3618 | 57 :" |
58 :" removing items with del | |
59 :py3 del l[2] | |
60 :$put =string(l) | |
61 :let l = range(8) | |
62 :py3 l=vim.bindeval('l') | |
63 :try | |
64 : py3 del l[:3] | |
65 : py3 del l[1:] | |
66 :catch | |
67 : $put =v:exception | |
68 :endtry | |
69 :$put =string(l) | |
70 :" | |
71 :py3 del d['-1'] | |
4631
4157fef7b950
updated for version 7.3.1063
Bram Moolenaar <bram@vim.org>
parents:
4629
diff
changeset
|
72 :py3 del d['f'] |
4627
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
73 :$put =string(py3eval('d.get(''b'', 1)')) |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
74 :$put =string(py3eval('d.pop(''b'')')) |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
75 :$put =string(py3eval('d.get(''b'', 1)')) |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
76 :$put =string(py3eval('d.pop(''1'', 2)')) |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
77 :$put =string(py3eval('d.pop(''1'', 2)')) |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
78 :$put =py3eval('repr(d.has_key(''0''))') |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
79 :$put =py3eval('repr(d.has_key(''1''))') |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
80 :$put =py3eval('repr(''0'' in d)') |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
81 :$put =py3eval('repr(''1'' in d)') |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
82 :$put =py3eval('repr(list(iter(d)))') |
3618 | 83 :$put =string(d) |
4698
2db005052371
updated for version 7.3.1096
Bram Moolenaar <bram@vim.org>
parents:
4684
diff
changeset
|
84 :$put =py3eval('repr(d.popitem())') |
4627
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
85 :$put =py3eval('repr(d.get(''0''))') |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
86 :$put =py3eval('repr(list(iter(d)))') |
3618 | 87 :" |
88 :" removing items out of range: silently skip items that don't exist | |
89 :let l = [0, 1, 2, 3] | |
90 :py3 l=vim.bindeval('l') | |
91 :" The following two ranges delete nothing as they match empty list: | |
92 :py3 del l[2:1] | |
93 :$put =string(l) | |
94 :py3 del l[2:2] | |
95 :$put =string(l) | |
96 :py3 del l[2:3] | |
97 :$put =string(l) | |
98 :let l = [0, 1, 2, 3] | |
99 :py3 l=vim.bindeval('l') | |
100 :py3 del l[2:4] | |
101 :$put =string(l) | |
102 :let l = [0, 1, 2, 3] | |
103 :py3 l=vim.bindeval('l') | |
104 :py3 del l[2:5] | |
105 :$put =string(l) | |
106 :let l = [0, 1, 2, 3] | |
107 :py3 l=vim.bindeval('l') | |
108 :py3 del l[2:6] | |
109 :$put =string(l) | |
110 :let l = [0, 1, 2, 3] | |
111 :py3 l=vim.bindeval('l') | |
112 :" The following two ranges delete nothing as they match empty list: | |
113 :py3 del l[-1:2] | |
114 :$put =string(l) | |
115 :py3 del l[-2:2] | |
116 :$put =string(l) | |
117 :py3 del l[-3:2] | |
118 :$put =string(l) | |
119 :let l = [0, 1, 2, 3] | |
120 :py3 l=vim.bindeval('l') | |
121 :py3 del l[-4:2] | |
122 :$put =string(l) | |
123 :let l = [0, 1, 2, 3] | |
124 :py3 l=vim.bindeval('l') | |
125 :py3 del l[-5:2] | |
126 :$put =string(l) | |
127 :let l = [0, 1, 2, 3] | |
128 :py3 l=vim.bindeval('l') | |
129 :py3 del l[-6:2] | |
130 :$put =string(l) | |
131 :" | |
132 :" Slice assignment to a list | |
133 :let l = [0, 1, 2, 3] | |
134 :py3 l=vim.bindeval('l') | |
135 :py3 l[0:0]=['a'] | |
136 :$put =string(l) | |
137 :let l = [0, 1, 2, 3] | |
138 :py3 l=vim.bindeval('l') | |
139 :py3 l[1:2]=['b'] | |
140 :$put =string(l) | |
141 :let l = [0, 1, 2, 3] | |
142 :py3 l=vim.bindeval('l') | |
143 :py3 l[2:4]=['c'] | |
144 :$put =string(l) | |
145 :let l = [0, 1, 2, 3] | |
146 :py3 l=vim.bindeval('l') | |
147 :py3 l[4:4]=['d'] | |
148 :$put =string(l) | |
149 :let l = [0, 1, 2, 3] | |
150 :py3 l=vim.bindeval('l') | |
151 :py3 l[-1:2]=['e'] | |
152 :$put =string(l) | |
153 :let l = [0, 1, 2, 3] | |
154 :py3 l=vim.bindeval('l') | |
155 :py3 l[-10:2]=['f'] | |
156 :$put =string(l) | |
157 :let l = [0, 1, 2, 3] | |
158 :py3 l=vim.bindeval('l') | |
159 :py3 l[2:-10]=['g'] | |
160 :$put =string(l) | |
161 :let l = [] | |
162 :py3 l=vim.bindeval('l') | |
163 :py3 l[0:0]=['h'] | |
164 :$put =string(l) | |
165 :" | |
166 :" Locked variables | |
167 :let l = [0, 1, 2, 3] | |
168 :py3 l=vim.bindeval('l') | |
169 :lockvar! l | |
170 :py3 l[2]='i' | |
171 :$put =string(l) | |
172 :unlockvar! l | |
173 :" | |
174 :" Function calls | |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
175 :fun New(...) |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
176 : return ['NewStart']+a:000+['NewEnd'] |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
177 :endfun |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
178 :fun DictNew(...) dict |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
179 : return ['DictNewStart']+a:000+['DictNewEnd', self] |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
180 :endfun |
3618 | 181 :let l=[function('New'), function('DictNew')] |
182 :py3 l=vim.bindeval('l') | |
183 :py3 l.extend(list(l[0](1, 2, 3))) | |
184 :$put =string(l) | |
185 :py3 l.extend(list(l[1](1, 2, 3, self={'a': 'b'}))) | |
186 :$put =string(l) | |
187 :py3 l+=[l[0].name] | |
188 :$put =string(l) | |
189 :try | |
190 : py3 l[1](1, 2, 3) | |
191 :catch | |
192 : $put =v:exception[:13] | |
193 :endtry | |
4631
4157fef7b950
updated for version 7.3.1063
Bram Moolenaar <bram@vim.org>
parents:
4629
diff
changeset
|
194 :py3 f=l[0] |
3618 | 195 :delfunction New |
196 :try | |
4631
4157fef7b950
updated for version 7.3.1063
Bram Moolenaar <bram@vim.org>
parents:
4629
diff
changeset
|
197 : py3 f(1, 2, 3) |
3618 | 198 :catch |
199 : $put =v:exception[:13] | |
200 :endtry | |
201 :if has('float') | |
202 : let l=[0.0] | |
203 : py3 l=vim.bindeval('l') | |
204 : py3 l.extend([0.0]) | |
205 : $put =string(l) | |
206 :else | |
207 : $put ='[0.0, 0.0]' | |
208 :endif | |
3802 | 209 :let messages=[] |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
210 :delfunction DictNew |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
211 py3 <<EOF |
3802 | 212 d=vim.bindeval('{}') |
213 m=vim.bindeval('messages') | |
4627
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
214 def em(expr, g=globals(), l=locals()): |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
215 try: |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
216 exec(expr, g, l) |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
217 except Exception as e: |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
218 m.extend([e.__class__.__name__]) |
3802 | 219 |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
220 em('d["abc1"]') |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
221 em('d["abc1"]="\\0"') |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
222 em('d["abc1"]=vim') |
4627
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
223 em('d[""]=1') |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
224 em('d["a\\0b"]=1') |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
225 em('d[b"a\\0b"]=1') |
3802 | 226 |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
227 em('d.pop("abc1")') |
4698
2db005052371
updated for version 7.3.1096
Bram Moolenaar <bram@vim.org>
parents:
4684
diff
changeset
|
228 em('d.popitem()') |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
229 del em |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
230 del m |
3802 | 231 EOF |
232 :$put =messages | |
3828 | 233 :unlet messages |
234 :" locked and scope attributes | |
235 :let d={} | let dl={} | lockvar dl | |
236 :for s in split("d dl v: g:") | |
237 : let name=tr(s, ':', 's') | |
238 : execute 'py3 '.name.'=vim.bindeval("'.s.'")' | |
239 : let toput=s.' : '.join(map(['locked', 'scope'], 'v:val.":".py3eval(name.".".v:val)'), ';') | |
240 : $put =toput | |
241 :endfor | |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
242 :silent! let d.abc2=1 |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
243 :silent! let dl.abc3=1 |
3828 | 244 :py3 d.locked=True |
245 :py3 dl.locked=False | |
246 :silent! let d.def=1 | |
247 :silent! let dl.def=1 | |
248 :put ='d:'.string(d) | |
249 :put ='dl:'.string(dl) | |
250 :unlet d dl | |
251 : | |
252 :let l=[] | let ll=[] | lockvar ll | |
253 :for s in split("l ll") | |
254 : let name=tr(s, ':', 's') | |
255 : execute 'py3 '.name.'=vim.bindeval("'.s.'")' | |
256 : let toput=s.' : locked:'.py3eval(name.'.locked') | |
257 : $put =toput | |
258 :endfor | |
259 :silent! call extend(l, [0]) | |
260 :silent! call extend(ll, [0]) | |
261 :py3 l.locked=True | |
262 :py3 ll.locked=False | |
263 :silent! call extend(l, [1]) | |
264 :silent! call extend(ll, [1]) | |
265 :put ='l:'.string(l) | |
266 :put ='ll:'.string(ll) | |
267 :unlet l ll | |
3618 | 268 :" |
269 :" py3eval() | |
270 :let l=py3eval('[0, 1, 2]') | |
271 :$put =string(l) | |
272 :let d=py3eval('{"a": "b", "c": 1, "d": ["e"]}') | |
273 :$put =sort(items(d)) | |
274 :if has('float') | |
275 : let f=py3eval('0.0') | |
276 : $put =string(f) | |
277 :else | |
278 : $put ='0.0' | |
279 :endif | |
3802 | 280 :" Invalid values: |
281 :for e in ['"\0"', '{"\0": 1}', 'undefined_name', 'vim'] | |
282 : try | |
283 : let v=py3eval(e) | |
284 : catch | |
285 : let toput=e.":\t".v:exception[:13] | |
286 : $put =toput | |
287 : endtry | |
288 :endfor | |
4109 | 289 :" |
290 :" threading | |
291 :let l = [0] | |
292 :py3 l=vim.bindeval('l') | |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
293 py3 <<EOF |
4109 | 294 import threading |
295 import time | |
296 | |
297 class T(threading.Thread): | |
298 def __init__(self): | |
299 threading.Thread.__init__(self) | |
300 self.t = 0 | |
301 self.running = True | |
302 | |
303 def run(self): | |
304 while self.running: | |
305 self.t += 1 | |
306 time.sleep(0.1) | |
307 | |
308 t = T() | |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
309 del T |
4109 | 310 t.start() |
311 EOF | |
312 :sleep 1 | |
313 :py3 t.running = False | |
314 :py3 t.join() | |
315 :py3 l[0] = t.t > 8 # check if the background thread is working | |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
316 :py3 del time |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
317 :py3 del threading |
4109 | 318 :$put =string(l) |
319 :" | |
320 :" settrace | |
321 :let l = [] | |
322 :py3 l=vim.bindeval('l') | |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
323 py3 <<EOF |
4109 | 324 import sys |
325 | |
326 def traceit(frame, event, arg): | |
327 global l | |
328 if event == "line": | |
329 l += [frame.f_lineno] | |
330 return traceit | |
331 | |
332 def trace_main(): | |
333 for i in range(5): | |
334 pass | |
335 EOF | |
336 :py3 sys.settrace(traceit) | |
337 :py3 trace_main() | |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
338 :py3 sys.settrace(None) |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
339 :py3 del traceit |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
340 :py3 del trace_main |
4109 | 341 :$put =string(l) |
4323 | 342 :" |
343 :" Vars | |
344 :let g:foo = 'bac' | |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
345 :let w:abc3 = 'def' |
4323 | 346 :let b:baz = 'bar' |
4413 | 347 :let t:bar = 'jkl' |
4323 | 348 :try |
349 : throw "Abc" | |
350 :catch | |
351 : put =py3eval('vim.vvars[''exception'']') | |
352 :endtry | |
353 :put =py3eval('vim.vars[''foo'']') | |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
354 :put =py3eval('vim.current.window.vars[''abc3'']') |
4323 | 355 :put =py3eval('vim.current.buffer.vars[''baz'']') |
4413 | 356 :put =py3eval('vim.current.tabpage.vars[''bar'']') |
4350 | 357 :" |
358 :" Options | |
359 :" paste: boolean, global | |
360 :" previewheight number, global | |
361 :" operatorfunc: string, global | |
362 :" number: boolean, window-local | |
363 :" numberwidth: number, window-local | |
364 :" colorcolumn: string, window-local | |
365 :" statusline: string, window-local/global | |
366 :" autoindent: boolean, buffer-local | |
4427 | 367 :" shiftwidth: number, buffer-local |
4350 | 368 :" omnifunc: string, buffer-local |
369 :" preserveindent: boolean, buffer-local/global | |
370 :" path: string, buffer-local/global | |
371 :let g:bufs=[bufnr('%')] | |
372 :new | |
373 :let g:bufs+=[bufnr('%')] | |
374 :vnew | |
375 :let g:bufs+=[bufnr('%')] | |
376 :wincmd j | |
377 :vnew | |
378 :let g:bufs+=[bufnr('%')] | |
379 :wincmd l | |
380 :fun RecVars(opt) | |
381 : let gval =string(eval('&g:'.a:opt)) | |
382 : let wvals=join(map(range(1, 4), 'v:val.":".string(getwinvar(v:val, "&".a:opt))')) | |
383 : let bvals=join(map(copy(g:bufs), 'v:val.":".string(getbufvar(v:val, "&".a:opt))')) | |
384 : put =' G: '.gval | |
385 : put =' W: '.wvals | |
386 : put =' B: '.wvals | |
387 :endfun | |
388 py3 << EOF | |
389 def e(s, g=globals(), l=locals()): | |
390 try: | |
391 exec(s, g, l) | |
392 except Exception as e: | |
4498 | 393 vim.command('return ' + repr(e.__class__.__name__)) |
4350 | 394 |
395 def ev(s, g=globals(), l=locals()): | |
396 try: | |
397 return eval(s, g, l) | |
398 except Exception as e: | |
4498 | 399 vim.command('let exc=' + repr(e.__class__.__name__)) |
4350 | 400 return 0 |
401 EOF | |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
402 :fun E(s) |
4350 | 403 : python3 e(vim.eval('a:s')) |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
404 :endfun |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
405 :fun Ev(s) |
4498 | 406 : let r=py3eval('ev(vim.eval("a:s"))') |
407 : if exists('exc') | |
408 : throw exc | |
409 : endif | |
410 : return r | |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
411 :endfun |
4350 | 412 :py3 gopts1=vim.options |
413 :py3 wopts1=vim.windows[2].options | |
414 :py3 wopts2=vim.windows[0].options | |
415 :py3 wopts3=vim.windows[1].options | |
416 :py3 bopts1=vim.buffers[vim.bindeval("g:bufs")[2]].options | |
417 :py3 bopts2=vim.buffers[vim.bindeval("g:bufs")[1]].options | |
418 :py3 bopts3=vim.buffers[vim.bindeval("g:bufs")[0]].options | |
4684
79522bb17125
updated for version 7.3.1089
Bram Moolenaar <bram@vim.org>
parents:
4663
diff
changeset
|
419 :set path=.,..,, |
4350 | 420 :let lst=[] |
421 :let lst+=[['paste', 1, 0, 1, 2, 1, 1, 0 ]] | |
422 :let lst+=[['previewheight', 5, 1, 6, 'a', 0, 1, 0 ]] | |
423 :let lst+=[['operatorfunc', 'A', 'B', 'C', 2, 0, 1, 0 ]] | |
424 :let lst+=[['number', 0, 1, 1, 0, 1, 0, 1 ]] | |
425 :let lst+=[['numberwidth', 2, 3, 5, -100, 0, 0, 1 ]] | |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
426 :let lst+=[['colorcolumn', '+1', '+2', '+3', 'abc4', 0, 0, 1 ]] |
4350 | 427 :let lst+=[['statusline', '1', '2', '4', 0, 0, 1, 1 ]] |
428 :let lst+=[['autoindent', 0, 1, 1, 2, 1, 0, 2 ]] | |
4427 | 429 :let lst+=[['shiftwidth', 0, 2, 1, 3, 0, 0, 2 ]] |
4350 | 430 :let lst+=[['omnifunc', 'A', 'B', 'C', 1, 0, 0, 2 ]] |
431 :let lst+=[['preserveindent', 0, 1, 1, 2, 1, 1, 2 ]] | |
432 :let lst+=[['path', '.,,', ',,', '.', 0, 0, 1, 2 ]] | |
433 :for [oname, oval1, oval2, oval3, invval, bool, global, local] in lst | |
434 : py3 oname=vim.eval('oname') | |
435 : py3 oval1=vim.bindeval('oval1') | |
436 : py3 oval2=vim.bindeval('oval2') | |
437 : py3 oval3=vim.bindeval('oval3') | |
438 : if invval is 0 || invval is 1 | |
439 : py3 invval=bool(vim.bindeval('invval')) | |
440 : else | |
441 : py3 invval=vim.bindeval('invval') | |
442 : endif | |
443 : if bool | |
444 : py3 oval1=bool(oval1) | |
445 : py3 oval2=bool(oval2) | |
446 : py3 oval3=bool(oval3) | |
447 : endif | |
448 : put ='>>> '.oname | |
449 : for v in ['gopts1', 'wopts1', 'bopts1'] | |
450 : try | |
451 : put =' p/'.v.': '.Ev('repr('.v.'['''.oname.'''])') | |
452 : catch | |
453 : put =' p/'.v.'! '.v:exception | |
454 : endtry | |
4498 | 455 : let r=E(v.'['''.oname.''']=invval') |
456 : if r isnot 0 | |
457 : put =' inv: '.string(invval).'! '.r | |
458 : endif | |
4350 | 459 : for vv in (v is# 'gopts1' ? [v] : [v, v[:-2].'2', v[:-2].'3']) |
460 : let val=substitute(vv, '^.opts', 'oval', '') | |
4498 | 461 : let r=E(vv.'['''.oname.''']='.val) |
462 : if r isnot 0 | |
463 : put =' '.vv.'! '.r | |
464 : endif | |
4350 | 465 : endfor |
466 : endfor | |
467 : call RecVars(oname) | |
468 : for v in ['wopts3', 'bopts3'] | |
4498 | 469 : let r=E('del '.v.'["'.oname.'"]') |
470 : if r isnot 0 | |
471 : put =' del '.v.'! '.r | |
472 : endif | |
4350 | 473 : endfor |
474 : call RecVars(oname) | |
475 :endfor | |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
476 :delfunction RecVars |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
477 :delfunction E |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
478 :delfunction Ev |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
479 :py3 del ev |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
480 :py3 del e |
4350 | 481 :only |
4397 | 482 :for buf in g:bufs[1:] |
483 : execute 'bwipeout!' buf | |
484 :endfor | |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
485 :py3 del gopts1 |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
486 :py3 del wopts1 |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
487 :py3 del wopts2 |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
488 :py3 del wopts3 |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
489 :py3 del bopts1 |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
490 :py3 del bopts2 |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
491 :py3 del bopts3 |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
492 :py3 del oval1 |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
493 :py3 del oval2 |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
494 :py3 del oval3 |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
495 :py3 del oname |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
496 :py3 del invval |
4389 | 497 :" |
498 :" Test buffer object | |
499 :vnew | |
500 :put ='First line' | |
501 :put ='Second line' | |
502 :put ='Third line' | |
503 :1 delete _ | |
504 :py3 b=vim.current.buffer | |
505 :wincmd w | |
506 :mark a | |
4589
fa39483a1363
updated for version 7.3.1042
Bram Moolenaar <bram@vim.org>
parents:
4511
diff
changeset
|
507 :augroup BUFS |
fa39483a1363
updated for version 7.3.1042
Bram Moolenaar <bram@vim.org>
parents:
4511
diff
changeset
|
508 : autocmd BufFilePost * python3 cb.append(vim.eval('expand("<abuf>")') + ':BufFilePost:' + vim.eval('bufnr("%")')) |
fa39483a1363
updated for version 7.3.1042
Bram Moolenaar <bram@vim.org>
parents:
4511
diff
changeset
|
509 : autocmd BufFilePre * python3 cb.append(vim.eval('expand("<abuf>")') + ':BufFilePre:' + vim.eval('bufnr("%")')) |
fa39483a1363
updated for version 7.3.1042
Bram Moolenaar <bram@vim.org>
parents:
4511
diff
changeset
|
510 :augroup END |
4389 | 511 py3 << EOF |
512 cb = vim.current.buffer | |
513 # Tests BufferAppend and BufferItem | |
514 cb.append(b[0]) | |
515 # Tests BufferSlice and BufferAssSlice | |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
516 cb.append('abc5') # Will be overwritten |
4389 | 517 cb[-1:] = b[:-2] |
518 # Test BufferLength and BufferAssSlice | |
519 cb.append('def') # Will not be overwritten | |
520 cb[len(cb):] = b[:] | |
521 # Test BufferAssItem and BufferMark | |
522 cb.append('ghi') # Will be overwritten | |
523 cb[-1] = repr((len(cb) - cb.mark('a')[0], cb.mark('a')[1])) | |
524 # Test BufferRepr | |
525 cb.append(repr(cb) + repr(b)) | |
526 # Modify foreign buffer | |
527 b.append('foo') | |
528 b[0]='bar' | |
529 b[0:0]=['baz'] | |
530 vim.command('call append("$", getbufline(%i, 1, "$"))' % b.number) | |
4589
fa39483a1363
updated for version 7.3.1042
Bram Moolenaar <bram@vim.org>
parents:
4511
diff
changeset
|
531 # Test assigning to name property |
4684
79522bb17125
updated for version 7.3.1089
Bram Moolenaar <bram@vim.org>
parents:
4663
diff
changeset
|
532 import os |
4589
fa39483a1363
updated for version 7.3.1042
Bram Moolenaar <bram@vim.org>
parents:
4511
diff
changeset
|
533 old_name = cb.name |
fa39483a1363
updated for version 7.3.1042
Bram Moolenaar <bram@vim.org>
parents:
4511
diff
changeset
|
534 cb.name = 'foo' |
4684
79522bb17125
updated for version 7.3.1089
Bram Moolenaar <bram@vim.org>
parents:
4663
diff
changeset
|
535 cb.append(cb.name[-11:].replace(os.path.sep, '/')) |
4589
fa39483a1363
updated for version 7.3.1042
Bram Moolenaar <bram@vim.org>
parents:
4511
diff
changeset
|
536 b.name = 'bar' |
4684
79522bb17125
updated for version 7.3.1089
Bram Moolenaar <bram@vim.org>
parents:
4663
diff
changeset
|
537 cb.append(b.name[-11:].replace(os.path.sep, '/')) |
4589
fa39483a1363
updated for version 7.3.1042
Bram Moolenaar <bram@vim.org>
parents:
4511
diff
changeset
|
538 cb.name = old_name |
4684
79522bb17125
updated for version 7.3.1089
Bram Moolenaar <bram@vim.org>
parents:
4663
diff
changeset
|
539 cb.append(cb.name[-17:].replace(os.path.sep, '/')) |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
540 del old_name |
4389 | 541 # Test CheckBuffer |
4589
fa39483a1363
updated for version 7.3.1042
Bram Moolenaar <bram@vim.org>
parents:
4511
diff
changeset
|
542 for _b in vim.buffers: |
fa39483a1363
updated for version 7.3.1042
Bram Moolenaar <bram@vim.org>
parents:
4511
diff
changeset
|
543 if _b is not cb: |
fa39483a1363
updated for version 7.3.1042
Bram Moolenaar <bram@vim.org>
parents:
4511
diff
changeset
|
544 vim.command('bwipeout! ' + str(_b.number)) |
fa39483a1363
updated for version 7.3.1042
Bram Moolenaar <bram@vim.org>
parents:
4511
diff
changeset
|
545 del _b |
4593
0cf552b325b5
updated for version 7.3.1044
Bram Moolenaar <bram@vim.org>
parents:
4589
diff
changeset
|
546 cb.append('valid: b:%s, cb:%s' % (repr(b.valid), repr(cb.valid))) |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
547 for expr in ('b[1]','b[:] = ["A", "B"]','b[:]','b.append("abc6")'): |
4389 | 548 try: |
549 exec(expr) | |
550 except vim.error: | |
551 pass | |
552 else: | |
553 # Usually a SEGV here | |
554 # Should not happen in any case | |
555 cb.append('No exception for ' + expr) | |
4589
fa39483a1363
updated for version 7.3.1042
Bram Moolenaar <bram@vim.org>
parents:
4511
diff
changeset
|
556 vim.command('cd .') |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
557 del b |
4389 | 558 EOF |
4397 | 559 :" |
560 :" Test vim.buffers object | |
561 :set hidden | |
562 :edit a | |
563 :buffer # | |
564 :edit b | |
565 :buffer # | |
566 :edit c | |
567 :buffer # | |
568 py3 << EOF | |
569 # Check GCing iterator that was not fully exhausted | |
570 i = iter(vim.buffers) | |
571 cb.append('i:' + str(next(i))) | |
572 # and also check creating more then one iterator at a time | |
573 i2 = iter(vim.buffers) | |
574 cb.append('i2:' + str(next(i2))) | |
575 cb.append('i:' + str(next(i))) | |
576 # The following should trigger GC and not cause any problems | |
577 del i | |
578 del i2 | |
579 i3 = iter(vim.buffers) | |
580 cb.append('i3:' + str(next(i3))) | |
581 del i3 | |
582 | |
583 prevnum = 0 | |
584 for b in vim.buffers: | |
585 # Check buffer order | |
586 if prevnum >= b.number: | |
587 cb.append('!!! Buffer numbers not in strictly ascending order') | |
588 # Check indexing: vim.buffers[number].number == number | |
589 cb.append(str(b.number) + ':' + repr(vim.buffers[b.number]) + '=' + repr(b)) | |
590 prevnum = b.number | |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
591 del prevnum |
4397 | 592 |
593 cb.append(str(len(vim.buffers))) | |
594 | |
595 bnums = list(map(lambda b: b.number, vim.buffers))[1:] | |
596 | |
597 # Test wiping out buffer with existing iterator | |
598 i4 = iter(vim.buffers) | |
599 cb.append('i4:' + str(next(i4))) | |
600 vim.command('bwipeout! ' + str(bnums.pop(0))) | |
601 try: | |
602 next(i4) | |
603 except vim.error: | |
604 pass | |
605 else: | |
606 cb.append('!!!! No vim.error') | |
607 i4 = iter(vim.buffers) | |
608 vim.command('bwipeout! ' + str(bnums.pop(-1))) | |
609 vim.command('bwipeout! ' + str(bnums.pop(-1))) | |
610 cb.append('i4:' + str(next(i4))) | |
611 try: | |
612 next(i4) | |
613 except StopIteration: | |
614 cb.append('StopIteration') | |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
615 del i4 |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
616 del bnums |
4397 | 617 EOF |
4413 | 618 :" |
619 :" Test vim.{tabpage,window}list and vim.{tabpage,window} objects | |
620 :tabnew 0 | |
621 :tabnew 1 | |
622 :vnew a.1 | |
623 :tabnew 2 | |
624 :vnew a.2 | |
625 :vnew b.2 | |
626 :vnew c.2 | |
627 py3 << EOF | |
4511
ce94a870b59b
updated for version 7.3.1003
Bram Moolenaar <bram@vim.org>
parents:
4498
diff
changeset
|
628 cb.append('Number of tabs: ' + str(len(vim.tabpages))) |
ce94a870b59b
updated for version 7.3.1003
Bram Moolenaar <bram@vim.org>
parents:
4498
diff
changeset
|
629 cb.append('Current tab pages:') |
ce94a870b59b
updated for version 7.3.1003
Bram Moolenaar <bram@vim.org>
parents:
4498
diff
changeset
|
630 |
4413 | 631 def W(w): |
632 if '(unknown)' in repr(w): | |
633 return '<window object (unknown)>' | |
634 else: | |
635 return repr(w) | |
4511
ce94a870b59b
updated for version 7.3.1003
Bram Moolenaar <bram@vim.org>
parents:
4498
diff
changeset
|
636 |
ce94a870b59b
updated for version 7.3.1003
Bram Moolenaar <bram@vim.org>
parents:
4498
diff
changeset
|
637 def Cursor(w, start=len(cb)): |
ce94a870b59b
updated for version 7.3.1003
Bram Moolenaar <bram@vim.org>
parents:
4498
diff
changeset
|
638 if w.buffer is cb: |
ce94a870b59b
updated for version 7.3.1003
Bram Moolenaar <bram@vim.org>
parents:
4498
diff
changeset
|
639 return repr((start - w.cursor[0], w.cursor[1])) |
ce94a870b59b
updated for version 7.3.1003
Bram Moolenaar <bram@vim.org>
parents:
4498
diff
changeset
|
640 else: |
ce94a870b59b
updated for version 7.3.1003
Bram Moolenaar <bram@vim.org>
parents:
4498
diff
changeset
|
641 return repr(w.cursor) |
ce94a870b59b
updated for version 7.3.1003
Bram Moolenaar <bram@vim.org>
parents:
4498
diff
changeset
|
642 |
4413 | 643 for t in vim.tabpages: |
644 cb.append(' ' + repr(t) + '(' + str(t.number) + ')' + ': ' + str(len(t.windows)) + ' windows, current is ' + W(t.window)) | |
645 cb.append(' Windows:') | |
646 for w in t.windows: | |
4511
ce94a870b59b
updated for version 7.3.1003
Bram Moolenaar <bram@vim.org>
parents:
4498
diff
changeset
|
647 cb.append(' ' + W(w) + '(' + str(w.number) + ')' + ': displays buffer ' + repr(w.buffer) + '; cursor is at ' + Cursor(w)) |
4413 | 648 # Other values depend on the size of the terminal, so they are checked partly: |
649 for attr in ('height', 'row', 'width', 'col'): | |
650 try: | |
651 aval = getattr(w, attr) | |
652 if type(aval) is not int: | |
653 raise TypeError | |
654 if aval < 0: | |
655 raise ValueError | |
656 except Exception as e: | |
657 cb.append('!!!!!! Error while getting attribute ' + attr + ': ' + e.__class__.__name__) | |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
658 del aval |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
659 del attr |
4413 | 660 w.cursor = (len(w.buffer), 0) |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
661 del W |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
662 del Cursor |
4413 | 663 cb.append('Number of windows in current tab page: ' + str(len(vim.windows))) |
664 if list(vim.windows) != list(vim.current.tabpage.windows): | |
665 cb.append('!!!!!! Windows differ') | |
666 EOF | |
667 :" | |
668 :" Test vim.current | |
669 py3 << EOF | |
670 def H(o): | |
671 return repr(o) | |
672 cb.append('Current tab page: ' + repr(vim.current.tabpage)) | |
673 cb.append('Current window: ' + repr(vim.current.window) + ': ' + H(vim.current.window) + ' is ' + H(vim.current.tabpage.window)) | |
674 cb.append('Current buffer: ' + repr(vim.current.buffer) + ': ' + H(vim.current.buffer) + ' is ' + H(vim.current.window.buffer)+ ' is ' + H(vim.current.tabpage.window.buffer)) | |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
675 del H |
4413 | 676 # Assigning: fails |
677 try: | |
678 vim.current.window = vim.tabpages[0].window | |
679 except ValueError: | |
680 cb.append('ValueError at assigning foreign tab window') | |
681 | |
682 for attr in ('window', 'tabpage', 'buffer'): | |
683 try: | |
684 setattr(vim.current, attr, None) | |
685 except TypeError: | |
686 cb.append('Type error at assigning None to vim.current.' + attr) | |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
687 del attr |
4413 | 688 |
689 # Assigning: success | |
690 vim.current.tabpage = vim.tabpages[-2] | |
691 vim.current.buffer = cb | |
692 vim.current.window = vim.windows[0] | |
693 vim.current.window.cursor = (len(vim.current.buffer), 0) | |
694 cb.append('Current tab page: ' + repr(vim.current.tabpage)) | |
695 cb.append('Current window: ' + repr(vim.current.window)) | |
696 cb.append('Current buffer: ' + repr(vim.current.buffer)) | |
697 cb.append('Current line: ' + repr(vim.current.line)) | |
4593
0cf552b325b5
updated for version 7.3.1044
Bram Moolenaar <bram@vim.org>
parents:
4589
diff
changeset
|
698 ws = list(vim.windows) |
0cf552b325b5
updated for version 7.3.1044
Bram Moolenaar <bram@vim.org>
parents:
4589
diff
changeset
|
699 ts = list(vim.tabpages) |
4413 | 700 for b in vim.buffers: |
701 if b is not cb: | |
702 vim.command('bwipeout! ' + str(b.number)) | |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
703 del b |
4593
0cf552b325b5
updated for version 7.3.1044
Bram Moolenaar <bram@vim.org>
parents:
4589
diff
changeset
|
704 cb.append('w.valid: ' + repr([w.valid for w in ws])) |
0cf552b325b5
updated for version 7.3.1044
Bram Moolenaar <bram@vim.org>
parents:
4589
diff
changeset
|
705 cb.append('t.valid: ' + repr([t.valid for t in ts])) |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
706 del w |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
707 del t |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
708 del ts |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
709 del ws |
4413 | 710 EOF |
711 :tabonly! | |
712 :only! | |
4496 | 713 :" |
714 :" Test types | |
715 py3 << EOF | |
716 for expr, attr in ( | |
717 ('vim.vars', 'Dictionary'), | |
718 ('vim.options', 'Options'), | |
719 ('vim.bindeval("{}")', 'Dictionary'), | |
720 ('vim.bindeval("[]")', 'List'), | |
721 ('vim.bindeval("function(\'tr\')")', 'Function'), | |
722 ('vim.current.buffer', 'Buffer'), | |
723 ('vim.current.range', 'Range'), | |
724 ('vim.current.window', 'Window'), | |
725 ('vim.current.tabpage', 'TabPage'), | |
726 ): | |
727 cb.append(expr + ':' + attr + ':' + repr(type(eval(expr)) is getattr(vim, attr))) | |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
728 del expr |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
729 del attr |
4496 | 730 EOF |
4498 | 731 :" |
4599
89bec74fd793
updated for version 7.3.1047
Bram Moolenaar <bram@vim.org>
parents:
4593
diff
changeset
|
732 :" Test __dir__() method |
89bec74fd793
updated for version 7.3.1047
Bram Moolenaar <bram@vim.org>
parents:
4593
diff
changeset
|
733 py3 << EOF |
89bec74fd793
updated for version 7.3.1047
Bram Moolenaar <bram@vim.org>
parents:
4593
diff
changeset
|
734 for name, o in ( |
89bec74fd793
updated for version 7.3.1047
Bram Moolenaar <bram@vim.org>
parents:
4593
diff
changeset
|
735 ('current', vim.current), |
89bec74fd793
updated for version 7.3.1047
Bram Moolenaar <bram@vim.org>
parents:
4593
diff
changeset
|
736 ('buffer', vim.current.buffer), |
89bec74fd793
updated for version 7.3.1047
Bram Moolenaar <bram@vim.org>
parents:
4593
diff
changeset
|
737 ('window', vim.current.window), |
89bec74fd793
updated for version 7.3.1047
Bram Moolenaar <bram@vim.org>
parents:
4593
diff
changeset
|
738 ('tabpage', vim.current.tabpage), |
89bec74fd793
updated for version 7.3.1047
Bram Moolenaar <bram@vim.org>
parents:
4593
diff
changeset
|
739 ('range', vim.current.range), |
89bec74fd793
updated for version 7.3.1047
Bram Moolenaar <bram@vim.org>
parents:
4593
diff
changeset
|
740 ('dictionary', vim.bindeval('{}')), |
89bec74fd793
updated for version 7.3.1047
Bram Moolenaar <bram@vim.org>
parents:
4593
diff
changeset
|
741 ('list', vim.bindeval('[]')), |
89bec74fd793
updated for version 7.3.1047
Bram Moolenaar <bram@vim.org>
parents:
4593
diff
changeset
|
742 ('function', vim.bindeval('function("tr")')), |
89bec74fd793
updated for version 7.3.1047
Bram Moolenaar <bram@vim.org>
parents:
4593
diff
changeset
|
743 ('output', sys.stdout), |
89bec74fd793
updated for version 7.3.1047
Bram Moolenaar <bram@vim.org>
parents:
4593
diff
changeset
|
744 ): |
89bec74fd793
updated for version 7.3.1047
Bram Moolenaar <bram@vim.org>
parents:
4593
diff
changeset
|
745 cb.append(name + ':' + ','.join(dir(o))) |
89bec74fd793
updated for version 7.3.1047
Bram Moolenaar <bram@vim.org>
parents:
4593
diff
changeset
|
746 del name |
89bec74fd793
updated for version 7.3.1047
Bram Moolenaar <bram@vim.org>
parents:
4593
diff
changeset
|
747 del o |
89bec74fd793
updated for version 7.3.1047
Bram Moolenaar <bram@vim.org>
parents:
4593
diff
changeset
|
748 EOF |
89bec74fd793
updated for version 7.3.1047
Bram Moolenaar <bram@vim.org>
parents:
4593
diff
changeset
|
749 :" |
4629
e4e48d4ee040
updated for version 7.3.1062
Bram Moolenaar <bram@vim.org>
parents:
4627
diff
changeset
|
750 :" Test vim.*.__new__ |
4627
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
751 :$put =string(py3eval('vim.Dictionary({})')) |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
752 :$put =string(py3eval('vim.Dictionary(a=1)')) |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
753 :$put =string(py3eval('vim.Dictionary(((''a'', 1),))')) |
4629
e4e48d4ee040
updated for version 7.3.1062
Bram Moolenaar <bram@vim.org>
parents:
4627
diff
changeset
|
754 :$put =string(py3eval('vim.List()')) |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
755 :$put =string(py3eval('vim.List(iter(''abc7''))')) |
4631
4157fef7b950
updated for version 7.3.1063
Bram Moolenaar <bram@vim.org>
parents:
4629
diff
changeset
|
756 :$put =string(py3eval('vim.Function(''tr'')')) |
4619
90beab957ba9
updated for version 7.3.1057
Bram Moolenaar <bram@vim.org>
parents:
4599
diff
changeset
|
757 :" |
90beab957ba9
updated for version 7.3.1057
Bram Moolenaar <bram@vim.org>
parents:
4599
diff
changeset
|
758 :" Test stdout/stderr |
90beab957ba9
updated for version 7.3.1057
Bram Moolenaar <bram@vim.org>
parents:
4599
diff
changeset
|
759 :redir => messages |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
760 :py3 sys.stdout.write('abc8') ; sys.stdout.write('def') |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
761 :py3 sys.stderr.write('abc9') ; sys.stderr.write('def') |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
762 :py3 sys.stdout.writelines(iter('abcA')) |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
763 :py3 sys.stderr.writelines(iter('abcB')) |
4619
90beab957ba9
updated for version 7.3.1057
Bram Moolenaar <bram@vim.org>
parents:
4599
diff
changeset
|
764 :redir END |
90beab957ba9
updated for version 7.3.1057
Bram Moolenaar <bram@vim.org>
parents:
4599
diff
changeset
|
765 :$put =string(substitute(messages, '\d\+', '', 'g')) |
4627
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
766 :" Test subclassing |
4631
4157fef7b950
updated for version 7.3.1063
Bram Moolenaar <bram@vim.org>
parents:
4629
diff
changeset
|
767 :fun Put(...) |
4157fef7b950
updated for version 7.3.1063
Bram Moolenaar <bram@vim.org>
parents:
4629
diff
changeset
|
768 : $put =string(a:000) |
4157fef7b950
updated for version 7.3.1063
Bram Moolenaar <bram@vim.org>
parents:
4629
diff
changeset
|
769 : return a:000 |
4157fef7b950
updated for version 7.3.1063
Bram Moolenaar <bram@vim.org>
parents:
4629
diff
changeset
|
770 :endfun |
4627
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
771 py3 << EOF |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
772 class DupDict(vim.Dictionary): |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
773 def __setitem__(self, key, value): |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
774 super(DupDict, self).__setitem__(key, value) |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
775 super(DupDict, self).__setitem__('dup_' + key, value) |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
776 dd = DupDict() |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
777 dd['a'] = 'b' |
4629
e4e48d4ee040
updated for version 7.3.1062
Bram Moolenaar <bram@vim.org>
parents:
4627
diff
changeset
|
778 |
e4e48d4ee040
updated for version 7.3.1062
Bram Moolenaar <bram@vim.org>
parents:
4627
diff
changeset
|
779 class DupList(vim.List): |
e4e48d4ee040
updated for version 7.3.1062
Bram Moolenaar <bram@vim.org>
parents:
4627
diff
changeset
|
780 def __getitem__(self, idx): |
e4e48d4ee040
updated for version 7.3.1062
Bram Moolenaar <bram@vim.org>
parents:
4627
diff
changeset
|
781 return [super(DupList, self).__getitem__(idx)] * 2 |
e4e48d4ee040
updated for version 7.3.1062
Bram Moolenaar <bram@vim.org>
parents:
4627
diff
changeset
|
782 |
e4e48d4ee040
updated for version 7.3.1062
Bram Moolenaar <bram@vim.org>
parents:
4627
diff
changeset
|
783 dl = DupList() |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
784 dl2 = DupList(iter('abcC')) |
4629
e4e48d4ee040
updated for version 7.3.1062
Bram Moolenaar <bram@vim.org>
parents:
4627
diff
changeset
|
785 dl.extend(dl2[0]) |
4631
4157fef7b950
updated for version 7.3.1063
Bram Moolenaar <bram@vim.org>
parents:
4629
diff
changeset
|
786 |
4157fef7b950
updated for version 7.3.1063
Bram Moolenaar <bram@vim.org>
parents:
4629
diff
changeset
|
787 class DupFun(vim.Function): |
4157fef7b950
updated for version 7.3.1063
Bram Moolenaar <bram@vim.org>
parents:
4629
diff
changeset
|
788 def __call__(self, arg): |
4157fef7b950
updated for version 7.3.1063
Bram Moolenaar <bram@vim.org>
parents:
4629
diff
changeset
|
789 return super(DupFun, self).__call__(arg, arg) |
4157fef7b950
updated for version 7.3.1063
Bram Moolenaar <bram@vim.org>
parents:
4629
diff
changeset
|
790 |
4157fef7b950
updated for version 7.3.1063
Bram Moolenaar <bram@vim.org>
parents:
4629
diff
changeset
|
791 df = DupFun('Put') |
4627
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
792 EOF |
18ba89e06fab
updated for version 7.3.1061
Bram Moolenaar <bram@vim.org>
parents:
4619
diff
changeset
|
793 :$put =string(sort(keys(py3eval('dd')))) |
4629
e4e48d4ee040
updated for version 7.3.1062
Bram Moolenaar <bram@vim.org>
parents:
4627
diff
changeset
|
794 :$put =string(py3eval('dl')) |
e4e48d4ee040
updated for version 7.3.1062
Bram Moolenaar <bram@vim.org>
parents:
4627
diff
changeset
|
795 :$put =string(py3eval('dl2')) |
4631
4157fef7b950
updated for version 7.3.1063
Bram Moolenaar <bram@vim.org>
parents:
4629
diff
changeset
|
796 :$put =string(py3eval('df(2)')) |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
797 :$put =string(py3eval('dl') is# py3eval('dl')) |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
798 :$put =string(py3eval('dd') is# py3eval('dd')) |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
799 :$put =string(py3eval('df')) |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
800 :delfunction Put |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
801 py3 << EOF |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
802 del DupDict |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
803 del DupList |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
804 del DupFun |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
805 del dd |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
806 del dl |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
807 del dl2 |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
808 del df |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
809 EOF |
4619
90beab957ba9
updated for version 7.3.1057
Bram Moolenaar <bram@vim.org>
parents:
4599
diff
changeset
|
810 :" |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4698
diff
changeset
|
811 :" Test chdir |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4698
diff
changeset
|
812 py3 << EOF |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4698
diff
changeset
|
813 import os |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4698
diff
changeset
|
814 fnamemodify = vim.Function('fnamemodify') |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4698
diff
changeset
|
815 cb.append(str(fnamemodify('.', ':p:h:t'))) |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4698
diff
changeset
|
816 cb.append(vim.eval('@%')) |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4698
diff
changeset
|
817 os.chdir('..') |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4698
diff
changeset
|
818 cb.append(str(fnamemodify('.', ':p:h:t'))) |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4698
diff
changeset
|
819 cb.append(vim.eval('@%').replace(os.path.sep, '/')) |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4698
diff
changeset
|
820 os.chdir('testdir') |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4698
diff
changeset
|
821 cb.append(str(fnamemodify('.', ':p:h:t'))) |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4698
diff
changeset
|
822 cb.append(vim.eval('@%')) |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
823 del fnamemodify |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4698
diff
changeset
|
824 EOF |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4698
diff
changeset
|
825 :" |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
826 :" Test errors |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
827 :fun F() dict |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
828 :endfun |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
829 :fun D() |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
830 :endfun |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
831 py3 << EOF |
5143
29e57603bf6f
updated for version 7.3.1314
Bram Moolenaar <bram@vim.org>
parents:
5012
diff
changeset
|
832 import re |
29e57603bf6f
updated for version 7.3.1314
Bram Moolenaar <bram@vim.org>
parents:
5012
diff
changeset
|
833 |
29e57603bf6f
updated for version 7.3.1314
Bram Moolenaar <bram@vim.org>
parents:
5012
diff
changeset
|
834 py33_type_error_pattern = re.compile('^__call__\(\) takes (\d+) positional argument but (\d+) were given$') |
29e57603bf6f
updated for version 7.3.1314
Bram Moolenaar <bram@vim.org>
parents:
5012
diff
changeset
|
835 |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
836 def ee(expr, g=globals(), l=locals()): |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
837 try: |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
838 try: |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
839 exec(expr, g, l) |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
840 except Exception as e: |
4663
bce2051173f0
updated for version 7.3.1079
Bram Moolenaar <bram@vim.org>
parents:
4645
diff
changeset
|
841 if sys.version_info >= (3, 3) and e.__class__ is AttributeError and str(e).find('has no attribute')>=0 and not str(e).startswith("'vim."): |
bce2051173f0
updated for version 7.3.1079
Bram Moolenaar <bram@vim.org>
parents:
4645
diff
changeset
|
842 cb.append(expr + ':' + repr((e.__class__, AttributeError(str(e)[str(e).rfind(" '") + 2:-1])))) |
5143
29e57603bf6f
updated for version 7.3.1314
Bram Moolenaar <bram@vim.org>
parents:
5012
diff
changeset
|
843 elif sys.version_info >= (3, 3) and e.__class__ is ImportError and str(e).find('No module named \'') >= 0: |
29e57603bf6f
updated for version 7.3.1314
Bram Moolenaar <bram@vim.org>
parents:
5012
diff
changeset
|
844 cb.append(expr + ':' + repr((e.__class__, ImportError(str(e).replace("'", ''))))) |
29e57603bf6f
updated for version 7.3.1314
Bram Moolenaar <bram@vim.org>
parents:
5012
diff
changeset
|
845 elif sys.version_info >= (3, 3) and e.__class__ is TypeError: |
29e57603bf6f
updated for version 7.3.1314
Bram Moolenaar <bram@vim.org>
parents:
5012
diff
changeset
|
846 m = py33_type_error_pattern.search(str(e)) |
29e57603bf6f
updated for version 7.3.1314
Bram Moolenaar <bram@vim.org>
parents:
5012
diff
changeset
|
847 if m: |
29e57603bf6f
updated for version 7.3.1314
Bram Moolenaar <bram@vim.org>
parents:
5012
diff
changeset
|
848 msg = '__call__() takes exactly {0} positional argument ({1} given)'.format(m.group(1), m.group(2)) |
29e57603bf6f
updated for version 7.3.1314
Bram Moolenaar <bram@vim.org>
parents:
5012
diff
changeset
|
849 cb.append(expr + ':' + repr((e.__class__, TypeError(msg)))) |
29e57603bf6f
updated for version 7.3.1314
Bram Moolenaar <bram@vim.org>
parents:
5012
diff
changeset
|
850 else: |
29e57603bf6f
updated for version 7.3.1314
Bram Moolenaar <bram@vim.org>
parents:
5012
diff
changeset
|
851 cb.append(expr + ':' + repr((e.__class__, e))) |
4663
bce2051173f0
updated for version 7.3.1079
Bram Moolenaar <bram@vim.org>
parents:
4645
diff
changeset
|
852 else: |
bce2051173f0
updated for version 7.3.1079
Bram Moolenaar <bram@vim.org>
parents:
4645
diff
changeset
|
853 cb.append(expr + ':' + repr((e.__class__, e))) |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
854 else: |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
855 cb.append(expr + ':NOT FAILED') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
856 except Exception as e: |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
857 cb.append(expr + '::' + repr((e.__class__, e))) |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
858 |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
859 d = vim.Dictionary() |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
860 ned = vim.Dictionary(foo='bar', baz='abcD') |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
861 dl = vim.Dictionary(a=1) |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
862 dl.locked = True |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
863 l = vim.List() |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
864 ll = vim.List('abcE') |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
865 ll.locked = True |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
866 f = vim.Function('string') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
867 fd = vim.Function('F') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
868 fdel = vim.Function('D') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
869 vim.command('delfunction D') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
870 |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
871 def subexpr_test(expr, name, subexprs): |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
872 cb.append('>>> Testing %s using %s' % (name, expr)) |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
873 for subexpr in subexprs: |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
874 ee(expr % subexpr) |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
875 cb.append('<<< Finished') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
876 |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
877 def stringtochars_test(expr): |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
878 return subexpr_test(expr, 'StringToChars', ( |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
879 '1', # Fail type checks |
4663
bce2051173f0
updated for version 7.3.1079
Bram Moolenaar <bram@vim.org>
parents:
4645
diff
changeset
|
880 'b"\\0"', # Fail PyString_AsStringAndSize(object, , NULL) check |
bce2051173f0
updated for version 7.3.1079
Bram Moolenaar <bram@vim.org>
parents:
4645
diff
changeset
|
881 '"\\0"', # Fail PyString_AsStringAndSize(bytes, , NULL) check |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
882 )) |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
883 |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
884 class Mapping(object): |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
885 def __init__(self, d): |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
886 self.d = d |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
887 |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
888 def __getitem__(self, key): |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
889 return self.d[key] |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
890 |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
891 def keys(self): |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
892 return self.d.keys() |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
893 |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
894 def items(self): |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
895 return self.d.items() |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
896 |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
897 def convertfrompyobject_test(expr, recurse=True): |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
898 # pydict_to_tv |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
899 stringtochars_test(expr % '{%s : 1}') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
900 if recurse: |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
901 convertfrompyobject_test(expr % '{"abcF" : %s}', False) |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
902 # pymap_to_tv |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
903 stringtochars_test(expr % 'Mapping({%s : 1})') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
904 if recurse: |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
905 convertfrompyobject_test(expr % 'Mapping({"abcG" : %s})', False) |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
906 # pyseq_to_tv |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
907 iter_test(expr) |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
908 return subexpr_test(expr, 'ConvertFromPyObject', ( |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
909 'None', # Not conversible |
4706
bf917ee1fad2
updated for version 7.3.1100
Bram Moolenaar <bram@vim.org>
parents:
4704
diff
changeset
|
910 '{b"": 1}', # Empty key not allowed |
bf917ee1fad2
updated for version 7.3.1100
Bram Moolenaar <bram@vim.org>
parents:
4704
diff
changeset
|
911 '{"": 1}', # Same, but with unicode object |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
912 'FailingMapping()', # |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
913 'FailingMappingKey()', # |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
914 'FailingNumber()', # |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
915 )) |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
916 |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
917 def convertfrompymapping_test(expr): |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
918 convertfrompyobject_test(expr) |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
919 return subexpr_test(expr, 'ConvertFromPyMapping', ( |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
920 '[]', |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
921 )) |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
922 |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
923 def iter_test(expr): |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
924 return subexpr_test(expr, '*Iter*', ( |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
925 'FailingIter()', |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
926 'FailingIterNext()', |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
927 )) |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
928 |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
929 def number_test(expr, natural=False, unsigned=False): |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
930 if natural: |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
931 unsigned = True |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
932 return subexpr_test(expr, 'NumberToLong', ( |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
933 '[]', |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
934 'None', |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
935 ) + (('-1',) if unsigned else ()) |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
936 + (('0',) if natural else ())) |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
937 |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
938 class FailingTrue(object): |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
939 def __bool__(self): |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
940 raise NotImplementedError('bool') |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
941 |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
942 class FailingIter(object): |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
943 def __iter__(self): |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
944 raise NotImplementedError('iter') |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
945 |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
946 class FailingIterNext(object): |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
947 def __iter__(self): |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
948 return self |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
949 |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
950 def __next__(self): |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
951 raise NotImplementedError('next') |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
952 |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
953 class FailingMappingKey(object): |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
954 def __getitem__(self, item): |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
955 raise NotImplementedError('getitem:mappingkey') |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
956 |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
957 def keys(self): |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
958 return list("abcH") |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
959 |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
960 class FailingMapping(object): |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
961 def __getitem__(self): |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
962 raise NotImplementedError('getitem:mapping') |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
963 |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
964 def keys(self): |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
965 raise NotImplementedError('keys') |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
966 |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
967 class FailingList(list): |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
968 def __getitem__(self, idx): |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
969 if i == 2: |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
970 raise NotImplementedError('getitem:list') |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
971 else: |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
972 return super(FailingList, self).__getitem__(idx) |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
973 |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
974 class NoArgsCall(object): |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
975 def __call__(self): |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
976 pass |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
977 |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
978 class FailingCall(object): |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
979 def __call__(self, path): |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
980 raise NotImplementedError('call') |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
981 |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
982 class FailingNumber(object): |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
983 def __int__(self): |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
984 raise NotImplementedError('int') |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
985 |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
986 cb.append("> Output") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
987 cb.append(">> OutputSetattr") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
988 ee('del sys.stdout.softspace') |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
989 number_test('sys.stdout.softspace = %s', unsigned=True) |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
990 number_test('sys.stderr.softspace = %s', unsigned=True) |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
991 ee('sys.stdout.attr = None') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
992 cb.append(">> OutputWrite") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
993 ee('sys.stdout.write(None)') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
994 cb.append(">> OutputWriteLines") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
995 ee('sys.stdout.writelines(None)') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
996 ee('sys.stdout.writelines([1])') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
997 iter_test('sys.stdout.writelines(%s)') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
998 cb.append("> VimCommand") |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
999 stringtochars_test('vim.command(%s)') |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1000 ee('vim.command("", 2)') |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1001 #! Not checked: vim->python exceptions translating: checked later |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1002 cb.append("> VimToPython") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1003 #! Not checked: everything: needs errors in internal python functions |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1004 cb.append("> VimEval") |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1005 stringtochars_test('vim.eval(%s)') |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1006 ee('vim.eval("", FailingTrue())') |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1007 #! Not checked: everything: needs errors in internal python functions |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1008 cb.append("> VimEvalPy") |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1009 stringtochars_test('vim.bindeval(%s)') |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1010 ee('vim.eval("", 2)') |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1011 #! Not checked: vim->python exceptions translating: checked later |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1012 cb.append("> VimStrwidth") |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1013 stringtochars_test('vim.strwidth(%s)') |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1014 cb.append("> VimForeachRTP") |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1015 ee('vim.foreach_rtp(None)') |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1016 ee('vim.foreach_rtp(NoArgsCall())') |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1017 ee('vim.foreach_rtp(FailingCall())') |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1018 ee('vim.foreach_rtp(int, 2)') |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1019 cb.append('> import') |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1020 old_rtp = vim.options['rtp'] |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1021 vim.options['rtp'] = os.getcwd().replace(',', '\\,').replace('\\', '\\\\') |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1022 ee('import xxx_no_such_module_xxx') |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1023 ee('import failing_import') |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1024 ee('import failing') |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1025 vim.options['rtp'] = old_rtp |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1026 del old_rtp |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1027 cb.append("> Dictionary") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1028 cb.append(">> DictionaryConstructor") |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1029 ee('vim.Dictionary("abcI")') |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1030 ##! Not checked: py_dict_alloc failure |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1031 cb.append(">> DictionarySetattr") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1032 ee('del d.locked') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1033 ee('d.locked = FailingTrue()') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1034 ee('vim.vvars.locked = False') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1035 ee('d.scope = True') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1036 ee('d.xxx = True') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1037 cb.append(">> _DictionaryItem") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1038 ee('d.get("a", 2, 3)') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1039 stringtochars_test('d.get(%s)') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1040 ee('d.pop("a")') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1041 ee('dl.pop("a")') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1042 cb.append(">> DictionaryIterNext") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1043 ee('for i in ned: ned["a"] = 1') |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1044 del i |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1045 cb.append(">> DictionaryAssItem") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1046 ee('dl["b"] = 1') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1047 stringtochars_test('d[%s] = 1') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1048 convertfrompyobject_test('d["a"] = %s') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1049 cb.append(">> DictionaryUpdate") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1050 cb.append(">>> kwargs") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1051 cb.append(">>> iter") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1052 ee('d.update(FailingMapping())') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1053 ee('d.update([FailingIterNext()])') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1054 iter_test('d.update(%s)') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1055 convertfrompyobject_test('d.update(%s)') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1056 stringtochars_test('d.update(((%s, 0),))') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1057 convertfrompyobject_test('d.update((("a", %s),))') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1058 cb.append(">> DictionaryPopItem") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1059 ee('d.popitem(1, 2)') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1060 cb.append(">> DictionaryHasKey") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1061 ee('d.has_key()') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1062 cb.append("> List") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1063 cb.append(">> ListConstructor") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1064 ee('vim.List(1, 2)') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1065 ee('vim.List(a=1)') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1066 iter_test('vim.List(%s)') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1067 convertfrompyobject_test('vim.List([%s])') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1068 cb.append(">> ListItem") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1069 ee('l[1000]') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1070 cb.append(">> ListAssItem") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1071 ee('ll[1] = 2') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1072 ee('l[1000] = 3') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1073 cb.append(">> ListAssSlice") |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1074 ee('ll[1:100] = "abcJ"') |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1075 iter_test('l[:] = %s') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1076 convertfrompyobject_test('l[:] = [%s]') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1077 cb.append(">> ListConcatInPlace") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1078 iter_test('l.extend(%s)') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1079 convertfrompyobject_test('l.extend([%s])') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1080 cb.append(">> ListSetattr") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1081 ee('del l.locked') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1082 ee('l.locked = FailingTrue()') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1083 ee('l.xxx = True') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1084 cb.append("> Function") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1085 cb.append(">> FunctionConstructor") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1086 ee('vim.Function("123")') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1087 ee('vim.Function("xxx_non_existent_function_xxx")') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1088 ee('vim.Function("xxx#non#existent#function#xxx")') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1089 cb.append(">> FunctionCall") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1090 convertfrompyobject_test('f(%s)') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1091 convertfrompymapping_test('fd(self=%s)') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1092 cb.append("> TabPage") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1093 cb.append(">> TabPageAttr") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1094 ee('vim.current.tabpage.xxx') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1095 cb.append("> TabList") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1096 cb.append(">> TabListItem") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1097 ee('vim.tabpages[1000]') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1098 cb.append("> Window") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1099 cb.append(">> WindowAttr") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1100 ee('vim.current.window.xxx') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1101 cb.append(">> WindowSetattr") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1102 ee('vim.current.window.buffer = 0') |
4663
bce2051173f0
updated for version 7.3.1079
Bram Moolenaar <bram@vim.org>
parents:
4645
diff
changeset
|
1103 ee('vim.current.window.cursor = (100000000, 100000000)') |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1104 ee('vim.current.window.cursor = True') |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1105 number_test('vim.current.window.height = %s', unsigned=True) |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1106 number_test('vim.current.window.width = %s', unsigned=True) |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1107 ee('vim.current.window.xxxxxx = True') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1108 cb.append("> WinList") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1109 cb.append(">> WinListItem") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1110 ee('vim.windows[1000]') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1111 cb.append("> Buffer") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1112 cb.append(">> StringToLine (indirect)") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1113 ee('vim.current.buffer[0] = "\\na"') |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1114 ee('vim.current.buffer[0] = b"\\na"') |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1115 cb.append(">> SetBufferLine (indirect)") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1116 ee('vim.current.buffer[0] = True') |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1117 cb.append(">> SetBufferLineList (indirect)") |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1118 ee('vim.current.buffer[:] = True') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1119 ee('vim.current.buffer[:] = ["\\na", "bc"]') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1120 cb.append(">> InsertBufferLines (indirect)") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1121 ee('vim.current.buffer.append(None)') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1122 ee('vim.current.buffer.append(["\\na", "bc"])') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1123 ee('vim.current.buffer.append("\\nbc")') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1124 cb.append(">> RBItem") |
4663
bce2051173f0
updated for version 7.3.1079
Bram Moolenaar <bram@vim.org>
parents:
4645
diff
changeset
|
1125 ee('vim.current.buffer[100000000]') |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1126 cb.append(">> RBAsItem") |
4663
bce2051173f0
updated for version 7.3.1079
Bram Moolenaar <bram@vim.org>
parents:
4645
diff
changeset
|
1127 ee('vim.current.buffer[100000000] = ""') |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1128 cb.append(">> BufferAttr") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1129 ee('vim.current.buffer.xxx') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1130 cb.append(">> BufferSetattr") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1131 ee('vim.current.buffer.name = True') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1132 ee('vim.current.buffer.xxx = True') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1133 cb.append(">> BufferMark") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1134 ee('vim.current.buffer.mark(0)') |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1135 ee('vim.current.buffer.mark("abcM")') |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1136 ee('vim.current.buffer.mark("!")') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1137 cb.append(">> BufferRange") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1138 ee('vim.current.buffer.range(1, 2, 3)') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1139 cb.append("> BufMap") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1140 cb.append(">> BufMapItem") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1141 ee('vim.buffers[100000000]') |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1142 number_test('vim.buffers[%s]', natural=True) |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1143 cb.append("> Current") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1144 cb.append(">> CurrentGetattr") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1145 ee('vim.current.xxx') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1146 cb.append(">> CurrentSetattr") |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1147 ee('vim.current.line = True') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1148 ee('vim.current.buffer = True') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1149 ee('vim.current.window = True') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1150 ee('vim.current.tabpage = True') |
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1151 ee('vim.current.xxx = True') |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1152 del d |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1153 del ned |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1154 del dl |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1155 del l |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1156 del ll |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1157 del f |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1158 del fd |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1159 del fdel |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1160 del subexpr_test |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1161 del stringtochars_test |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1162 del Mapping |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1163 del convertfrompyobject_test |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1164 del convertfrompymapping_test |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1165 del iter_test |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1166 del number_test |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1167 del FailingTrue |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1168 del FailingIter |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1169 del FailingIterNext |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1170 del FailingMapping |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1171 del FailingMappingKey |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1172 del FailingList |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1173 del NoArgsCall |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1174 del FailingCall |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1175 del FailingNumber |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1176 EOF |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1177 :delfunction F |
4637
4c46e1487c63
updated for version 7.3.1066
Bram Moolenaar <bram@vim.org>
parents:
4631
diff
changeset
|
1178 :" |
4839
d59ff2114733
updated for version 7.3.1166
Bram Moolenaar <bram@vim.org>
parents:
4833
diff
changeset
|
1179 :" Test import |
d59ff2114733
updated for version 7.3.1166
Bram Moolenaar <bram@vim.org>
parents:
4833
diff
changeset
|
1180 py3 << EOF |
4851
96e154e825a7
updated for version 7.3.1172
Bram Moolenaar <bram@vim.org>
parents:
4839
diff
changeset
|
1181 sys.path.insert(0, os.path.join(os.getcwd(), 'python_before')) |
96e154e825a7
updated for version 7.3.1172
Bram Moolenaar <bram@vim.org>
parents:
4839
diff
changeset
|
1182 sys.path.append(os.path.join(os.getcwd(), 'python_after')) |
4839
d59ff2114733
updated for version 7.3.1166
Bram Moolenaar <bram@vim.org>
parents:
4833
diff
changeset
|
1183 vim.options['rtp'] = os.getcwd().replace(',', '\\,').replace('\\', '\\\\') |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1184 l = [] |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1185 def callback(path): |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1186 l.append(os.path.relpath(path)) |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1187 vim.foreach_rtp(callback) |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1188 cb.append(repr(l)) |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1189 del l |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1190 def callback(path): |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1191 return os.path.relpath(path) |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1192 cb.append(repr(vim.foreach_rtp(callback))) |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1193 del callback |
4839
d59ff2114733
updated for version 7.3.1166
Bram Moolenaar <bram@vim.org>
parents:
4833
diff
changeset
|
1194 from module import dir as d |
d59ff2114733
updated for version 7.3.1166
Bram Moolenaar <bram@vim.org>
parents:
4833
diff
changeset
|
1195 from modulex import ddir |
d59ff2114733
updated for version 7.3.1166
Bram Moolenaar <bram@vim.org>
parents:
4833
diff
changeset
|
1196 cb.append(d + ',' + ddir) |
4851
96e154e825a7
updated for version 7.3.1172
Bram Moolenaar <bram@vim.org>
parents:
4839
diff
changeset
|
1197 import before |
96e154e825a7
updated for version 7.3.1172
Bram Moolenaar <bram@vim.org>
parents:
4839
diff
changeset
|
1198 cb.append(before.dir) |
96e154e825a7
updated for version 7.3.1172
Bram Moolenaar <bram@vim.org>
parents:
4839
diff
changeset
|
1199 import after |
96e154e825a7
updated for version 7.3.1172
Bram Moolenaar <bram@vim.org>
parents:
4839
diff
changeset
|
1200 cb.append(after.dir) |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1201 import topmodule as tm |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1202 import topmodule.submodule as tms |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1203 import topmodule.submodule.subsubmodule.subsubsubmodule as tmsss |
5012
6aecf486bb34
updated for version 7.3.1250
Bram Moolenaar <bram@vim.org>
parents:
4982
diff
changeset
|
1204 cb.append(tm.__file__.replace(os.path.sep, '/')[-len('modulex/topmodule/__init__.py'):]) |
6aecf486bb34
updated for version 7.3.1250
Bram Moolenaar <bram@vim.org>
parents:
4982
diff
changeset
|
1205 cb.append(tms.__file__.replace(os.path.sep, '/')[-len('modulex/topmodule/submodule/__init__.py'):]) |
6aecf486bb34
updated for version 7.3.1250
Bram Moolenaar <bram@vim.org>
parents:
4982
diff
changeset
|
1206 cb.append(tmsss.__file__.replace(os.path.sep, '/')[-len('modulex/topmodule/submodule/subsubmodule/subsubsubmodule.py'):]) |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1207 del before |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1208 del after |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1209 del d |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1210 del ddir |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1211 del tm |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1212 del tms |
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1213 del tmsss |
4839
d59ff2114733
updated for version 7.3.1166
Bram Moolenaar <bram@vim.org>
parents:
4833
diff
changeset
|
1214 EOF |
4833
70b1178dec79
updated for version 7.3.1163
Bram Moolenaar <bram@vim.org>
parents:
4706
diff
changeset
|
1215 :" |
4498 | 1216 :" Test exceptions |
1217 :fun Exe(e) | |
1218 : execute a:e | |
1219 :endfun | |
1220 py3 << EOF | |
1221 Exe = vim.bindeval('function("Exe")') | |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1222 ee('vim.command("throw \'abcN\'")') |
4498 | 1223 ee('Exe("throw \'def\'")') |
1224 ee('vim.eval("Exe(\'throw \'\'ghi\'\'\')")') | |
1225 ee('vim.eval("Exe(\'echoerr \'\'jkl\'\'\')")') | |
1226 ee('vim.eval("Exe(\'xxx_non_existent_command_xxx\')")') | |
1227 ee('vim.bindeval("Exe(\'xxx_non_existent_command_xxx\')")') | |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1228 del Exe |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1229 EOF |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1230 :delfunction Exe |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1231 :" |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1232 :" Cleanup |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1233 py3 << EOF |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1234 del cb |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1235 del ee |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1236 del sys |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1237 del os |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1238 del vim |
4498 | 1239 EOF |
3618 | 1240 :endfun |
1241 :" | |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1242 :fun RunTest() |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1243 :let checkrefs = !empty($PYTHONDUMPREFS) |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1244 :let start = getline(1, '$') |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1245 :for i in range(checkrefs ? 10 : 1) |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1246 : if i != 0 |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1247 : %d _ |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1248 : call setline(1, start) |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1249 : endif |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1250 : call Test() |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1251 : if i == 0 |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1252 : let result = getline(1, '$') |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1253 : endif |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1254 :endfor |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1255 :if checkrefs |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1256 : %d _ |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1257 : call setline(1, result) |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1258 :endif |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1259 :endfun |
3618 | 1260 :" |
4976
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1261 :call RunTest() |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1262 :delfunction RunTest |
4ed713442c51
updated for version 7.3.1233
Bram Moolenaar <bram@vim.org>
parents:
4851
diff
changeset
|
1263 :delfunction Test |
3618 | 1264 :call garbagecollect(1) |
1265 :" | |
1266 :/^start:/,$wq! test.out | |
4982
39980afcf54a
updated for version 7.3.1236
Bram Moolenaar <bram@vim.org>
parents:
4976
diff
changeset
|
1267 :" vim: et ts=4 isk-=\: |
4397 | 1268 :call getchar() |
3618 | 1269 ENDTEST |
1270 | |
1271 start: |