annotate src/testdir/test87.in @ 8259:99a70c3b902f v7.4.1422

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