summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0136
blob: 6594315040f7bef69110095906ee072a096f6784 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0136
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.0136
Problem:    Lua tests don't cover new features.
Solution:   Add more tests. (Dominique Pelle, closes #3130)
Files:	    runtime/doc/if_lua.txt, src/testdir/test_lua.vim


*** ../vim-8.1.0135/runtime/doc/if_lua.txt	2018-05-17 13:41:41.000000000 +0200
--- runtime/doc/if_lua.txt	2018-07-01 19:45:39.183210699 +0200
***************
*** 127,133 ****
  				rules. Example: >
  					:lua t = {math.pi, false, say = 'hi'}
  					:echo luaeval('vim.list(t)')
! 					:" [3.141593, 0], 'say' is ignored
  <
  	vim.dict([arg])		Returns an empty dictionary or, if "arg" is a
  				Lua table, returns a dict d such that d[k] =
--- 127,133 ----
  				rules. Example: >
  					:lua t = {math.pi, false, say = 'hi'}
  					:echo luaeval('vim.list(t)')
! 					:" [3.141593, v:false], 'say' is ignored
  <
  	vim.dict([arg])		Returns an empty dictionary or, if "arg" is a
  				Lua table, returns a dict d such that d[k] =
***************
*** 141,148 ****
  					:" {'say': 'hi'}, numeric keys ignored
  <
  	vim.funcref({name})	Returns a Funcref to function {name} (see
! 				|Funcref|). It is equivalent to Vim's
! 				"function". NOT IMPLEMENTED YET
  
  	vim.buffer([arg])	If "arg" is a number, returns buffer with
  				number "arg" in the buffer list or, if "arg"
--- 141,147 ----
  					:" {'say': 'hi'}, numeric keys ignored
  <
  	vim.funcref({name})	Returns a Funcref to function {name} (see
! 				|Funcref|). It is equivalent to Vim's function().
  
  	vim.buffer([arg])	If "arg" is a number, returns buffer with
  				number "arg" in the buffer list or, if "arg"
***************
*** 166,172 ****
  				or window, respectively. Examples: >
  					:lua l = vim.list()
  					:lua print(type(l), vim.type(l))
! 					:" userdata list
  <
  	vim.command({cmd})	Executes the vim (ex-mode) command {cmd}.
  				Examples: >
--- 165,171 ----
  				or window, respectively. Examples: >
  					:lua l = vim.list()
  					:lua print(type(l), vim.type(l))
! 					:" list
  <
  	vim.command({cmd})	Executes the vim (ex-mode) command {cmd}.
  				Examples: >
*** ../vim-8.1.0135/src/testdir/test_lua.vim	2018-07-01 15:12:00.224057865 +0200
--- src/testdir/test_lua.vim	2018-07-01 19:45:39.183210699 +0200
***************
*** 124,130 ****
    lua w2()
    call assert_equal('Xfoo2', bufname('%'))
  
!   lua w1, w2 = nil, nil
    %bwipe!
  endfunc
  
--- 124,130 ----
    lua w2()
    call assert_equal('Xfoo2', bufname('%'))
  
!   lua w1, w2 = nil
    %bwipe!
  endfunc
  
***************
*** 142,148 ****
    lua b2()
    call assert_equal('Xfoo2', bufname('%'))
  
!   lua b1, b2 = nil, nil
    %bwipe!
  endfunc
  
--- 142,148 ----
    lua b2()
    call assert_equal('Xfoo2', bufname('%'))
  
!   lua b1, b2, w1, w2 = nil
    %bwipe!
  endfunc
  
***************
*** 191,197 ****
    call assert_equal('Xfoo1', luaeval("vim.buffer(" . bn1 . ").name"))
    call assert_equal('Xfoo2', luaeval("vim.buffer(" . bn2 . ").name"))
  
!   lua bn1, bn2 = nil, nil
    %bwipe!
  endfunc
  
--- 191,197 ----
    call assert_equal('Xfoo1', luaeval("vim.buffer(" . bn1 . ").name"))
    call assert_equal('Xfoo2', luaeval("vim.buffer(" . bn2 . ").name"))
  
!   lua bn1, bn2 = nil
    %bwipe!
  endfunc
  
***************
*** 275,281 ****
    call assert_equal('Xfoo1', luaeval('vim.buffer().name'))
    call assert_equal('Xfoo1', bufname('%'))
  
!   lua bn, bp = nil, nil
    %bwipe!
  endfunc
  
--- 275,281 ----
    call assert_equal('Xfoo1', luaeval('vim.buffer().name'))
    call assert_equal('Xfoo1', bufname('%'))
  
!   lua bn, bp = nil
    %bwipe!
  endfunc
  
***************
*** 295,306 ****
  func Test_list()
    call assert_equal([], luaeval('vim.list()'))
  
-   " Same example as in :help lua-vim.
-   " FIXME: test is disabled because it does not work.
-   " See https://github.com/vim/vim/issues/3086
-   " lua t = {math.pi, false, say = 'hi'}
-   " call assert_equal([3.141593, 0], luaeval('vim.list(t)'))
- 
    let l = []
    lua l = vim.eval('l')
    lua l:add(123)
--- 295,300 ----
***************
*** 319,327 ****
--- 313,338 ----
    lua l:insert('xx', 3)
    call assert_equal(['first', 124.0, 'abc', 'xx', v:true, v:false, {'a': 1, 'b': 2, 'c': 3}], l)
  
+   lockvar 1 l
+   call assert_fails('lua l:add("x")', '[string "vim chunk"]:1: list is locked')
+ 
    lua l = nil
  endfunc
  
+ func Test_list_table()
+   " See :help lua-vim
+   " Non-numeric keys should not be used to initialize the list
+   " so say = 'hi' should be ignored.
+   lua t = {3.14, 'hello', false, true, say = 'hi'}
+   call assert_equal([3.14, 'hello', v:false, v:true], luaeval('vim.list(t)'))
+   lua t = nil
+ 
+   call assert_fails('lua vim.list(1)', '[string "vim chunk"]:1: table expected, got number')
+   call assert_fails('lua vim.list("x")', '[string "vim chunk"]:1: table expected, got string')
+   call assert_fails('lua vim.list(print)', '[string "vim chunk"]:1: table expected, got function')
+   call assert_fails('lua vim.list(true)', '[string "vim chunk"]:1: table expected, got boolean')
+ endfunc
+ 
  " Test l() i.e. iterator on list
  func Test_list_iter()
    lua l = vim.list():add('foo'):add('bar')
***************
*** 329,335 ****
    lua for v in l() do str = str .. v end
    call assert_equal('foobar', luaeval('str'))
  
!   lua str, v, l = nil, nil, nil
  endfunc
  
  func Test_recursive_list()
--- 340,346 ----
    lua for v in l() do str = str .. v end
    call assert_equal('foobar', luaeval('str'))
  
!   lua str, l = nil
  endfunc
  
  func Test_recursive_list()
***************
*** 359,370 ****
  func Test_dict()
    call assert_equal({}, luaeval('vim.dict()'))
  
-   " Same example as in :help lua-vim.
-   " FIXME: test is disabled because it does not work.
-   " See https://github.com/vim/vim/issues/3086
-   " lua t = {math.pi, false, say = 'hi'}
-   " call assert_equal({'say' : 'hi'}, luaeval('vim.dict(t)'))
- 
    let d = {}
    lua d = vim.eval('d')
    lua d[0] = 123
--- 370,375 ----
***************
*** 383,391 ****
--- 388,419 ----
    lua d[4] = nil
    call assert_equal({'0':124.0, '1':'abc', '2':v:true, '3':v:false, '5': {'a':1, 'b':2, 'c':3}}, d)
  
+   lockvar 1 d
+   call assert_fails('lua d[6] = 1', '[string "vim chunk"]:1: dict is locked')
+ 
    lua d = nil
  endfunc
  
+ func Test_dict_table()
+   lua t = {key1 = 'x', key2 = 3.14, key3 = true, key4 = false}
+   call assert_equal({'key1': 'x', 'key2': 3.14, 'key3': v:true, 'key4': v:false},
+         \           luaeval('vim.dict(t)'))
+ 
+   " Same example as in :help lua-vim.
+   lua t = {math.pi, false, say = 'hi'}
+   " FIXME: commented out as it currently does not work as documented:
+   " Expected {'say': 'hi'}
+   " but got {'1': 3.141593, '2': v:false, 'say': 'hi'}
+   " Is the documentation or the code wrong?
+   "call assert_equal({'say' : 'hi'}, luaeval('vim.dict(t)'))
+   lua t = nil
+ 
+   call assert_fails('lua vim.dict(1)', '[string "vim chunk"]:1: table expected, got number')
+   call assert_fails('lua vim.dict("x")', '[string "vim chunk"]:1: table expected, got string')
+   call assert_fails('lua vim.dict(print)', '[string "vim chunk"]:1: table expected, got function')
+   call assert_fails('lua vim.dict(true)', '[string "vim chunk"]:1: table expected, got boolean')
+ endfunc
+ 
  " Test d() i.e. iterator on dictionary
  func Test_dict_iter()
    let d = {'a': 1, 'b':2}
***************
*** 394,400 ****
    lua for k,v in d() do str = str .. k ..':' .. v .. ',' end
    call assert_equal('a:1,b:2,', luaeval('str'))
  
!   lua str, k, v, d = nil, nil, nil, nil
  endfunc
  
  func Test_funcref()
--- 422,428 ----
    lua for k,v in d() do str = str .. k ..':' .. v .. ',' end
    call assert_equal('a:1,b:2,', luaeval('str'))
  
!   lua str, d = nil
  endfunc
  
  func Test_funcref()
***************
*** 418,423 ****
--- 446,453 ----
    lua d.len = vim.funcref"Mylen" -- assign d as 'self'
    lua res = (d.len() == vim.funcref"len"(vim.eval"l")) and "OK" or "FAIL"
    call assert_equal("OK", luaeval('res'))
+ 
+   lua i1, i2, msg, d, res = nil
  endfunc
  
  " Test vim.type()
***************
*** 496,502 ****
    call assert_equal('hello', luaeval('str'))
    call assert_equal(123.0, luaeval('num'))
  
!   lua str, num = nil, nil
    call delete('Xlua_file')
  endfunc
  
--- 526,532 ----
    call assert_equal('hello', luaeval('str'))
    call assert_equal(123.0, luaeval('num'))
  
!   lua str, num = nil
    call delete('Xlua_file')
  endfunc
  
***************
*** 512,518 ****
    let msg = split(execute('message'), "\n")[-1]
    call assert_equal('str=foo, num=321', msg)
  
!   lua str, num = nil, nil
    call delete('Xlua_file')
    bwipe!
  endfunc
--- 542,560 ----
    let msg = split(execute('message'), "\n")[-1]
    call assert_equal('str=foo, num=321', msg)
  
!   lua str, num = nil
!   call delete('Xlua_file')
!   bwipe!
! endfunc
! 
! " Test :luafile with syntax error
! func Test_luafile_error()
!   new Xlua_file
!   call writefile(['nil = 0' ], 'Xlua_file')
!   call setfperm('Xlua_file', 'r-xr-xr-x')
! 
!   call assert_fails('luafile Xlua_file', "Xlua_file:1: unexpected symbol near 'nil'")
! 
    call delete('Xlua_file')
    bwipe!
  endfunc
*** ../vim-8.1.0135/src/version.c	2018-07-01 16:43:59.850736541 +0200
--- src/version.c	2018-07-01 19:47:47.126402301 +0200
***************
*** 791,792 ****
--- 791,794 ----
  {   /* Add new patch number below this line */
+ /**/
+     136,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
165. You have a web page burned into your glasses

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///