summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0221
blob: cef2ca8cef41180e02f821eaa339955669592c44 (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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0221
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.0221
Problem:    Not enough testing for the Ruby interface.
Solution:   Add more tests. (Dominique Pelle, closes #3252)
Files:	    runtime/doc/if_ruby.txt, src/testdir/test_ruby.vim


*** ../vim-8.1.0220/runtime/doc/if_ruby.txt	2018-05-17 13:41:41.000000000 +0200
--- runtime/doc/if_ruby.txt	2018-07-28 17:20:52.903932857 +0200
***************
*** 145,151 ****
  
  Methods:
  
! name		Returns the name of the buffer.
  number		Returns the number of the buffer.
  count		Returns the number of lines.
  length		Returns the number of lines.
--- 145,151 ----
  
  Methods:
  
! name		Returns the full name of the buffer.
  number		Returns the number of the buffer.
  count		Returns the number of lines.
  length		Returns the number of lines.
***************
*** 181,186 ****
--- 181,187 ----
  width		Returns the width of the window.
  width = {n}	Sets the window width to {n}.
  cursor		Returns a [row, col] array for the cursor position.
+ 		First line number is 1 and first column number is 0.
  cursor = [{row}, {col}]
  		Sets the cursor position to {row} and {col}.
  
*** ../vim-8.1.0220/src/testdir/test_ruby.vim	2018-07-28 17:18:05.164865356 +0200
--- src/testdir/test_ruby.vim	2018-07-28 17:27:53.037565797 +0200
***************
*** 4,9 ****
--- 4,16 ----
    finish
  end
  
+ " Helper function as there is no builtin rubyeval() function similar
+ " to perleval, luaevel() or pyeval().
+ func RubyEval(ruby_expr)
+   let s = split(execute('ruby print ' . a:ruby_expr), "\n")
+   return (len(s) == 0) ? '' : s[-1]
+ endfunc
+ 
  func Test_ruby_change_buffer()
    call setline(line('$'), ['1 line 1'])
    ruby Vim.command("normal /^1\n")
***************
*** 11,46 ****
    call assert_equal('1 changed line 1', getline('$'))
  endfunc
  
- func Test_ruby_evaluate_list()
-   call setline(line('$'), ['2 line 2'])
-   ruby Vim.command("normal /^2\n")
-   let l = ["abc", "def"]
-   ruby << EOF
-   curline = $curbuf.line_number
-   l = Vim.evaluate("l");
-   $curbuf.append(curline, l.join("\n"))
- EOF
-   normal j
-   .rubydo $_ = $_.gsub(/\n/, '/')
-   call assert_equal('abc/def', getline('$'))
- endfunc
- 
- func Test_ruby_evaluate_dict()
-   let d = {'a': 'foo', 'b': 123}
-   redir => l:out
-   ruby d = Vim.evaluate("d"); print d
-   redir END
-   call assert_equal(['{"a"=>"foo", "b"=>123}'], split(l:out, "\n"))
- endfunc
- 
- func Test_ruby_evaluate_special_var()
-   let l = [v:true, v:false, v:null, v:none]
-   redir => l:out
-   ruby d = Vim.evaluate("l"); print d
-   redir END
-   call assert_equal(['[true, false, nil, nil]'], split(l:out, "\n"))
- endfunc
- 
  func Test_rubydo()
    " Check deleting lines does not trigger ml_get error.
    new
--- 18,23 ----
***************
*** 54,61 ****
    call setline(1, ['one', 'two', 'three'])
    rubydo Vim.command("new")
    call assert_equal(wincount + 1, winnr('$'))
!   bwipe!
!   bwipe!
  endfunc
  
  func Test_rubyfile()
--- 31,37 ----
    call setline(1, ['one', 'two', 'three'])
    rubydo Vim.command("new")
    call assert_equal(wincount + 1, winnr('$'))
!   %bwipe!
  endfunc
  
  func Test_rubyfile()
***************
*** 73,80 ****
--- 49,366 ----
    normal gg
    rubydo $curwin.cursor = [1, 5]
    call assert_equal([1, 6], [line('.'), col('.')])
+   call assert_equal('[1, 5]', RubyEval('$curwin.cursor'))
  
    " Check that movement after setting cursor position keeps current column.
    normal j
    call assert_equal([2, 6], [line('.'), col('.')])
+   call assert_equal('[2, 5]', RubyEval('$curwin.cursor'))
+ 
+   call assert_fails('ruby $curwin.cursor = [1]',
+         \           'ArgumentError: array length must be 2')
+   bwipe!
+ endfunc
+ 
+ " Test buffer.count and buffer.length (number of lines in buffer)
+ func Test_buffer_count()
+   new
+   call setline(1, ['one', 'two', 'three'])
+   call assert_equal('3', RubyEval('$curbuf.count'))
+   call assert_equal('3', RubyEval('$curbuf.length'))
+   bwipe!
+ endfunc
+ 
+ " Test buffer.name (buffer name)
+ func Test_buffer_name()
+   new Xfoo
+   call assert_equal(expand('%:p'), RubyEval('$curbuf.name'))
+   bwipe
+   call assert_equal('', RubyEval('$curbuf.name'))
+ endfunc
+ 
+ " Test buffer.number (number of the buffer).
+ func Test_buffer_number()
+   new
+   call assert_equal(string(bufnr('%')), RubyEval('$curbuf.number'))
+   new
+   call assert_equal(string(bufnr('%')), RubyEval('$curbuf.number'))
+ 
+   %bwipe
+ endfunc
+ 
+ " Test buffer.delete({n}) (delete line {n})
+ func Test_buffer_delete()
+   new
+   call setline(1, ['one', 'two', 'three'])
+   ruby $curbuf.delete(2)
+   call assert_equal(['one', 'three'], getline(1, '$'))
+ 
+   call assert_fails('ruby $curbuf.delete(0)', 'IndexError: line number 0 out of range')
+   call assert_fails('ruby $curbuf.delete(3)', 'IndexError: line number 3 out of range')
+ 
+   bwipe!
+ endfunc
+ 
+ " Test buffer.append({str}, str) (append line {str} after line {n})
+ func Test_buffer_append()
+   new
+   ruby $curbuf.append(0, 'one')
+   ruby $curbuf.append(1, 'three')
+   ruby $curbuf.append(1, 'two')
+   ruby $curbuf.append(4, 'four')
+ 
+   call assert_equal(['one', 'two', 'three', '', 'four'], getline(1, '$'))
+ 
+   call assert_fails('ruby $curbuf.append(-1, "x")',
+         \           'IndexError: line number -1 out of range')
+   call assert_fails('ruby $curbuf.append(6, "x")',
+         \           'IndexError: line number 6 out of range')
+ 
+   bwipe!
+ endfunc
+ 
+ " Test buffer.line (get or set the current line)
+ func Test_buffer_line()
+   new
+   call setline(1, ['one', 'two', 'three'])
+   2
+   call assert_equal('two', RubyEval('$curbuf.line'))
+ 
+   ruby $curbuf.line = 'TWO'
+   call assert_equal(['one', 'TWO', 'three'], getline(1, '$'))
+ 
+   bwipe!
+ endfunc
+ 
+ " Test buffer.line_number (get current line number)
+ func Test_buffer_line_number()
+   new
+   call setline(1, ['one', 'two', 'three'])
+   2
+   call assert_equal('2', RubyEval('$curbuf.line_number'))
+ 
+   bwipe!
+ endfunc
+ 
+ func Test_buffer_get()
+   new
+   call setline(1, ['one', 'two'])
+   call assert_equal('one', RubyEval('$curbuf[1]'))
+   call assert_equal('two', RubyEval('$curbuf[2]'))
+ 
+   call assert_fails('ruby $curbuf[0]',
+         \           'IndexError: line number 0 out of range')
+   call assert_fails('ruby $curbuf[3]',
+         \           'IndexError: line number 3 out of range')
+ 
+   bwipe!
+ endfunc
+ 
+ func Test_buffer_set()
+   new
+   call setline(1, ['one', 'two'])
+   ruby $curbuf[2] = 'TWO'
+   ruby $curbuf[1] = 'ONE'
+ 
+   call assert_fails('ruby $curbuf[0] = "ZERO"',
+         \           'IndexError: line number 0 out of range')
+   call assert_fails('ruby $curbuf[3] = "THREE"',
+         \           'IndexError: line number 3 out of range')
+   bwipe!
+ endfunc
+ 
+ " Test window.width (get or set window height).
+ func Test_window_height()
+   new
+ 
+   " Test setting window height
+   ruby $curwin.height = 2
+   call assert_equal(2, winheight(0))
+ 
+   " Test getting window height
+   call assert_equal('2', RubyEval('$curwin.height'))
+ 
+   bwipe
+ endfunc
+ 
+ " Test window.width (get or set window width).
+ func Test_window_width()
+   vnew
+ 
+   " Test setting window width
+   ruby $curwin.width = 2
+   call assert_equal(2, winwidth(0))
+ 
+   " Test getting window width
+   call assert_equal('2', RubyEval('$curwin.width'))
+ 
+   bwipe
+ endfunc
+ 
+ " Test window.buffer (get buffer object of a window object).
+ func Test_window_buffer()
+   new Xfoo1
+   new Xfoo2
+   ruby $b2 = $curwin.buffer
+   ruby $w2 = $curwin
+   wincmd j
+   ruby $b1 = $curwin.buffer
+   ruby $w1 = $curwin
+ 
+   call assert_equal(RubyEval('$b1'), RubyEval('$w1.buffer'))
+   call assert_equal(RubyEval('$b2'), RubyEval('$w2.buffer'))
+   call assert_equal(string(bufnr('Xfoo1')), RubyEval('$w1.buffer.number'))
+   call assert_equal(string(bufnr('Xfoo2')), RubyEval('$w2.buffer.number'))
+ 
+   ruby $b1, $w1, $b2, $w2 = nil
+   %bwipe
+ endfunc
+ 
+ " Test Vim::Window.current (get current window object)
+ func Test_Vim_window_current()
+   let cw = RubyEval('$curwin')
+   call assert_equal(cw, RubyEval('Vim::Window.current'))
+   call assert_match('^#<Vim::Window:0x\x\+>$', cw)
+ endfunc
+ 
+ " Test Vim::Window.count (number of windows)
+ func Test_Vim_window_count()
+   new Xfoo1
+   new Xfoo2
+   split
+   call assert_equal('4', RubyEval('Vim::Window.count'))
+   %bwipe
+   call assert_equal('1', RubyEval('Vim::Window.count'))
+ endfunc
+ 
+ " Test Vim::Window[n] (get window object of window n)
+ func Test_Vim_window_get()
+   new Xfoo1
+   new Xfoo2
+   call assert_match('Xfoo2$', RubyEval('Vim::Window[0].buffer.name'))
+   wincmd j
+   call assert_match('Xfoo1$', RubyEval('Vim::Window[1].buffer.name'))
+   wincmd j
+   call assert_equal('',       RubyEval('Vim::Window[2].buffer.name'))
+   %bwipe
+ endfunc
+ 
+ " Test Vim::Buffer.current (return the buffer object of current buffer)
+ func Test_Vim_buffer_current()
+   let cb = RubyEval('$curbuf')
+   call assert_equal(cb, RubyEval('Vim::Buffer.current'))
+   call assert_match('^#<Vim::Buffer:0x\x\+>$', cb)
+ endfunc
+ 
+ " Test Vim::Buffer:.count (return the number of buffers)
+ func Test_Vim_buffer_count()
+   new Xfoo1
+   new Xfoo2
+   call assert_equal('3', RubyEval('Vim::Buffer.count'))
+   %bwipe
+   call assert_equal('1', RubyEval('Vim::Buffer.count'))
+ endfunc
+ 
+ " Test Vim::buffer[n] (return the buffer object of buffer number n)
+ func Test_Vim_buffer_get()
+   new Xfoo1
+   new Xfoo2
+ 
+   " Index of Vim::Buffer[n] goes from 0 to the number of buffers.
+   call assert_equal('',       RubyEval('Vim::Buffer[0].name'))
+   call assert_match('Xfoo1$', RubyEval('Vim::Buffer[1].name'))
+   call assert_match('Xfoo2$', RubyEval('Vim::Buffer[2].name'))
+   call assert_fails('ruby print Vim::Buffer[3].name',
+         \           "NoMethodError: undefined method `name' for nil:NilClass")
+   %bwipe
+ endfunc
+ 
+ " Test Vim::command({cmd}) (execute a Ex command))
+ " Test Vim::command({cmd})
+ func Test_Vim_command()
+   new
+   call setline(1, ['one', 'two', 'three', 'four'])
+   ruby Vim::command('2,3d')
+   call assert_equal(['one', 'four'], getline(1, '$'))
+   bwipe!
+ endfunc
+ 
+ " Test Vim::set_option (set a vim option)
+ func Test_Vim_set_option()
+   call assert_equal(0, &number)
+   ruby Vim::set_option('number')
+   call assert_equal(1, &number)
+   ruby Vim::set_option('nonumber')
+   call assert_equal(0, &number)
+ endfunc
+ 
+ func Test_Vim_evaluate()
+   call assert_equal('123',      RubyEval('Vim::evaluate("123")'))
+   " Vim::evaluate("123").class gives Integer or Fixnum depending
+   " on versions of Ruby.
+   call assert_match('^Integer\|Fixnum$', RubyEval('Vim::evaluate("123").class'))
+ 
+   call assert_equal('1.23',     RubyEval('Vim::evaluate("1.23")'))
+   call assert_equal('Float',    RubyEval('Vim::evaluate("1.23").class'))
+ 
+   call assert_equal('foo',      RubyEval('Vim::evaluate("\"foo\"")'))
+   call assert_equal('String',   RubyEval('Vim::evaluate("\"foo\"").class'))
+ 
+   call assert_equal('[1, 2]',   RubyEval('Vim::evaluate("[1, 2]")'))
+   call assert_equal('Array',    RubyEval('Vim::evaluate("[1, 2]").class'))
+ 
+   call assert_equal('{"1"=>2}', RubyEval('Vim::evaluate("{1:2}")'))
+   call assert_equal('Hash',     RubyEval('Vim::evaluate("{1:2}").class'))
+ 
+   call assert_equal('',         RubyEval('Vim::evaluate("v:null")'))
+   call assert_equal('NilClass', RubyEval('Vim::evaluate("v:null").class'))
+ 
+   call assert_equal('',         RubyEval('Vim::evaluate("v:none")'))
+   call assert_equal('NilClass', RubyEval('Vim::evaluate("v:none").class'))
+ 
+   call assert_equal('true',      RubyEval('Vim::evaluate("v:true")'))
+   call assert_equal('TrueClass', RubyEval('Vim::evaluate("v:true").class'))
+   call assert_equal('false',     RubyEval('Vim::evaluate("v:false")'))
+   call assert_equal('FalseClass',RubyEval('Vim::evaluate("v:false").class'))
+ endfunc
+ 
+ func Test_Vim_evaluate_list()
+   call setline(line('$'), ['2 line 2'])
+   ruby Vim.command("normal /^2\n")
+   let l = ["abc", "def"]
+   ruby << EOF
+   curline = $curbuf.line_number
+   l = Vim.evaluate("l");
+   $curbuf.append(curline, l.join("\n"))
+ EOF
+   normal j
+   .rubydo $_ = $_.gsub(/\n/, '/')
+   call assert_equal('abc/def', getline('$'))
+ endfunc
+ 
+ func Test_Vim_evaluate_dict()
+   let d = {'a': 'foo', 'b': 123}
+   redir => l:out
+   ruby d = Vim.evaluate("d"); print d
+   redir END
+   call assert_equal(['{"a"=>"foo", "b"=>123}'], split(l:out, "\n"))
+ endfunc
+ 
+ " Test Vim::message({msg}) (display message {msg})
+ func Test_Vim_message()
+   ruby Vim::message('A message')
+   let messages = split(execute('message'), "\n")
+   call assert_equal('A message', messages[-1])
+ endfunc
+ 
+ func Test_print()
+   ruby print "Hello World!"
+   let messages = split(execute('message'), "\n")
+   call assert_equal('Hello World!', messages[-1])
+ endfunc
+ 
+ func Test_p()
+   ruby p 'Just a test'
+   let messages = split(execute('message'), "\n")
+   call assert_equal('"Just a test"', messages[-1])
  endfunc
*** ../vim-8.1.0220/src/version.c	2018-07-28 17:18:05.164865356 +0200
--- src/version.c	2018-07-28 17:22:07.999512544 +0200
***************
*** 800,801 ****
--- 800,803 ----
  {   /* Add new patch number below this line */
+ /**/
+     221,
  /**/

-- 
GUARD #1:  What, ridden on a horse?
ARTHUR:    Yes!
GUARD #1:  You're using coconuts!
ARTHUR:    What?
GUARD #1:  You've got two empty halves of coconut and you're bangin' 'em
           together.
                                  The Quest for the Holy Grail (Monty Python)

 /// 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    ///