annotate src/testdir/test87.in @ 5288:46cf49cc9289 v7.4b.020

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