blob: b7fc0734fe20f824ab1268d9e4a5b0dbef82311a [file] [log] [blame]
Bram Moolenaar71136db2019-11-30 19:48:46 +01001" Tests for register operations
Bram Moolenaar71136db2019-11-30 19:48:46 +01002
Bram Moolenaar54c8d222019-12-02 20:41:39 +01003source check.vim
Bram Moolenaar11a5b192020-07-10 21:17:51 +02004source view_util.vim
Bram Moolenaar54c8d222019-12-02 20:41:39 +01005
Bram Moolenaar71136db2019-11-30 19:48:46 +01006" This test must be executed first to check for empty and unset registers.
7func Test_aaa_empty_reg_test()
8 call assert_fails('normal @@', 'E748:')
9 call assert_fails('normal @%', 'E354:')
10 call assert_fails('normal @#', 'E354:')
11 call assert_fails('normal @!', 'E354:')
12 call assert_fails('normal @:', 'E30:')
13 call assert_fails('normal @.', 'E29:')
Bram Moolenaar6f1f0ca2019-12-01 18:16:18 +010014 call assert_fails('put /', 'E35:')
15 call assert_fails('put .', 'E29:')
Bram Moolenaar71136db2019-11-30 19:48:46 +010016endfunc
Bram Moolenaare45deb72017-07-16 17:56:16 +020017
18func Test_yank_shows_register()
19 enew
20 set report=0
21 call setline(1, ['foo', 'bar'])
22 " Line-wise
23 exe 'norm! yy'
24 call assert_equal('1 line yanked', v:statusmsg)
25 exe 'norm! "zyy'
26 call assert_equal('1 line yanked into "z', v:statusmsg)
27 exe 'norm! yj'
28 call assert_equal('2 lines yanked', v:statusmsg)
29 exe 'norm! "zyj'
30 call assert_equal('2 lines yanked into "z', v:statusmsg)
31
32 " Block-wise
33 exe "norm! \<C-V>y"
34 call assert_equal('block of 1 line yanked', v:statusmsg)
35 exe "norm! \<C-V>\"zy"
36 call assert_equal('block of 1 line yanked into "z', v:statusmsg)
37 exe "norm! \<C-V>jy"
38 call assert_equal('block of 2 lines yanked', v:statusmsg)
39 exe "norm! \<C-V>j\"zy"
40 call assert_equal('block of 2 lines yanked into "z', v:statusmsg)
41
42 bwipe!
43endfunc
Bram Moolenaar7ce551f2018-05-06 17:32:19 +020044
45func Test_display_registers()
46 e file1
47 e file2
48 call setline(1, ['foo', 'bar'])
49 /bar
50 exe 'norm! y2l"axx'
51 call feedkeys("i\<C-R>=2*4\n\<esc>")
52 call feedkeys(":ls\n", 'xt')
53
54 let a = execute('display')
55 let b = execute('registers')
56
57 call assert_equal(a, b)
Bram Moolenaar3691f1e2019-10-24 20:17:00 +020058 call assert_match('^\nType Name Content\n'
59 \ . ' c "" a\n'
60 \ . ' c "0 ba\n'
61 \ . ' c "a b\n'
Bram Moolenaar7ce551f2018-05-06 17:32:19 +020062 \ . '.*'
Bram Moolenaar3691f1e2019-10-24 20:17:00 +020063 \ . ' c "- a\n'
Bram Moolenaar7ce551f2018-05-06 17:32:19 +020064 \ . '.*'
Bram Moolenaar3691f1e2019-10-24 20:17:00 +020065 \ . ' c ": ls\n'
66 \ . ' c "% file2\n'
67 \ . ' c "# file1\n'
68 \ . ' c "/ bar\n'
69 \ . ' c "= 2\*4', a)
Bram Moolenaar7ce551f2018-05-06 17:32:19 +020070
71 let a = execute('registers a')
Bram Moolenaar3691f1e2019-10-24 20:17:00 +020072 call assert_match('^\nType Name Content\n'
73 \ . ' c "a b', a)
Bram Moolenaar7ce551f2018-05-06 17:32:19 +020074
75 let a = execute('registers :')
Bram Moolenaar3691f1e2019-10-24 20:17:00 +020076 call assert_match('^\nType Name Content\n'
77 \ . ' c ": ls', a)
Bram Moolenaar7ce551f2018-05-06 17:32:19 +020078
79 bwipe!
80endfunc
Bram Moolenaar9d7fdd42019-03-08 09:50:52 +010081
82func Test_register_one()
83 " delete a line goes into register one
84 new
85 call setline(1, "one")
86 normal dd
87 call assert_equal("one\n", @1)
88
89 " delete a word does not change register one, does change "-
90 call setline(1, "two")
91 normal de
92 call assert_equal("one\n", @1)
93 call assert_equal("two", @-)
94
95 " delete a word with a register does not change register one
96 call setline(1, "three")
97 normal "ade
98 call assert_equal("three", @a)
99 call assert_equal("one\n", @1)
100
101 " delete a word with register DOES change register one with one of a list of
102 " operators
103 " %
104 call setline(1, ["(12)3"])
105 normal "ad%
106 call assert_equal("(12)", @a)
107 call assert_equal("(12)", @1)
108
109 " (
110 call setline(1, ["first second"])
111 normal $"ad(
112 call assert_equal("first secon", @a)
113 call assert_equal("first secon", @1)
114
115 " )
116 call setline(1, ["First Second."])
117 normal gg0"ad)
118 call assert_equal("First Second.", @a)
119 call assert_equal("First Second.", @1)
120
121 " `
122 call setline(1, ["start here."])
123 normal gg0fhmx0"ad`x
124 call assert_equal("start ", @a)
125 call assert_equal("start ", @1)
126
127 " /
128 call setline(1, ["searchX"])
129 exe "normal gg0\"ad/X\<CR>"
130 call assert_equal("search", @a)
131 call assert_equal("search", @1)
132
133 " ?
134 call setline(1, ["Ysearch"])
135 exe "normal gg$\"ad?Y\<CR>"
136 call assert_equal("Ysearc", @a)
137 call assert_equal("Ysearc", @1)
138
139 " n
140 call setline(1, ["Ynext"])
141 normal gg$"adn
142 call assert_equal("Ynex", @a)
143 call assert_equal("Ynex", @1)
144
145 " N
146 call setline(1, ["prevY"])
147 normal gg0"adN
148 call assert_equal("prev", @a)
149 call assert_equal("prev", @1)
150
151 " }
152 call setline(1, ["one", ""])
153 normal gg0"ad}
154 call assert_equal("one\n", @a)
155 call assert_equal("one\n", @1)
156
157 " {
158 call setline(1, ["", "two"])
159 normal 2G$"ad{
160 call assert_equal("\ntw", @a)
161 call assert_equal("\ntw", @1)
162
163 bwipe!
164endfunc
Bram Moolenaar6edbbd82019-03-10 09:41:51 +0100165
Bram Moolenaar11a5b192020-07-10 21:17:51 +0200166func Test_recording_status_in_ex_line()
167 norm qx
168 redraw!
169 call assert_equal('recording @x', Screenline(&lines))
170 set shortmess=q
171 redraw!
172 call assert_equal('recording', Screenline(&lines))
173 set shortmess&
174 norm q
175 redraw!
176 call assert_equal('', Screenline(&lines))
177endfunc
178
Bram Moolenaar6edbbd82019-03-10 09:41:51 +0100179" Check that replaying a typed sequence does not use an Esc and following
180" characters as an escape sequence.
181func Test_recording_esc_sequence()
182 new
Bram Moolenaar55d81cd2019-03-11 08:05:50 +0100183 try
184 let save_F2 = &t_F2
185 catch
186 endtry
Bram Moolenaar6edbbd82019-03-10 09:41:51 +0100187 let t_F2 = "\<Esc>OQ"
188 call feedkeys("qqiTest\<Esc>", "xt")
189 call feedkeys("OQuirk\<Esc>q", "xt")
190 call feedkeys("Go\<Esc>@q", "xt")
191 call assert_equal(['Quirk', 'Test', 'Quirk', 'Test'], getline(1, 4))
192 bwipe!
Bram Moolenaar55d81cd2019-03-11 08:05:50 +0100193 if exists('save_F2')
Bram Moolenaara5e44602019-05-25 21:52:30 +0200194 let &t_F2 = save_F2
Bram Moolenaar037c54f2019-04-20 23:47:46 +0200195 else
196 set t_F2=
Bram Moolenaar55d81cd2019-03-11 08:05:50 +0100197 endif
Bram Moolenaar6edbbd82019-03-10 09:41:51 +0100198endfunc
Bram Moolenaar71136db2019-11-30 19:48:46 +0100199
200" Test for executing the last used register (@)
201func Test_last_used_exec_reg()
202 " Test for the @: command
203 let a = ''
204 call feedkeys(":let a ..= 'Vim'\<CR>", 'xt')
205 normal @:
206 call assert_equal('VimVim', a)
207
208 " Test for the @= command
209 let x = ''
210 let a = ":let x ..= 'Vim'\<CR>"
211 exe "normal @=a\<CR>"
212 normal @@
213 call assert_equal('VimVim', x)
214
215 " Test for the @. command
216 let a = ''
217 call feedkeys("i:let a ..= 'Edit'\<CR>", 'xt')
218 normal @.
219 normal @@
220 call assert_equal('EditEdit', a)
221
Bram Moolenaar6f1f0ca2019-12-01 18:16:18 +0100222 " Test for repeating the last command-line in visual mode
223 call append(0, 'register')
224 normal gg
225 let @r = ''
226 call feedkeys("v:yank R\<CR>", 'xt')
227 call feedkeys("v@:", 'xt')
228 call assert_equal("\nregister\nregister\n", @r)
229
Bram Moolenaar71136db2019-11-30 19:48:46 +0100230 enew!
231endfunc
232
233func Test_get_register()
234 enew
235 edit Xfile1
236 edit Xfile2
237 call assert_equal('Xfile2', getreg('%'))
238 call assert_equal('Xfile1', getreg('#'))
239
240 call feedkeys("iTwo\<Esc>", 'xt')
241 call assert_equal('Two', getreg('.'))
242 call assert_equal('', getreg('_'))
243 call assert_beeps('normal ":yy')
244 call assert_beeps('normal "%yy')
245 call assert_beeps('normal ".yy')
246
247 call assert_equal('', getreg("\<C-F>"))
248 call assert_equal('', getreg("\<C-W>"))
249 call assert_equal('', getreg("\<C-L>"))
Bram Moolenaar0e05de42020-03-25 22:23:46 +0100250 " Change the last used register to '"' for the next test
251 normal! ""yy
252 let @" = 'happy'
253 call assert_equal('happy', getreg())
254 call assert_equal('happy', getreg(''))
Bram Moolenaar71136db2019-11-30 19:48:46 +0100255
256 call assert_equal('', getregtype('!'))
Bram Moolenaar0e05de42020-03-25 22:23:46 +0100257 call assert_fails('echo getregtype([])', 'E730:')
258 call assert_equal('v', getregtype())
259 call assert_equal('v', getregtype(''))
Bram Moolenaar71136db2019-11-30 19:48:46 +0100260
Bram Moolenaar6f1f0ca2019-12-01 18:16:18 +0100261 " Test for inserting an invalid register content
262 call assert_beeps('exe "normal i\<C-R>!"')
263
264 " Test for inserting a register with multiple lines
265 call deletebufline('', 1, '$')
266 call setreg('r', ['a', 'b'])
267 exe "normal i\<C-R>r"
268 call assert_equal(['a', 'b', ''], getline(1, '$'))
269
270 " Test for inserting a multi-line register in the command line
271 call feedkeys(":\<C-R>r\<Esc>", 'xt')
272 call assert_equal("a\rb\r", histget(':', -1))
273
Bram Moolenaar99fa7212020-04-26 15:59:55 +0200274 call assert_fails('let r = getreg("=", [])', 'E745:')
275 call assert_fails('let r = getreg("=", 1, [])', 'E745:')
Bram Moolenaar71136db2019-11-30 19:48:46 +0100276 enew!
277endfunc
278
279func Test_set_register()
280 call assert_fails("call setreg('#', 200)", 'E86:')
281
282 edit Xfile_alt_1
283 let b1 = bufnr('')
284 edit Xfile_alt_2
285 let b2 = bufnr('')
286 edit Xfile_alt_3
287 let b3 = bufnr('')
288 call setreg('#', 'alt_1')
289 call assert_equal('Xfile_alt_1', getreg('#'))
290 call setreg('#', b2)
291 call assert_equal('Xfile_alt_2', getreg('#'))
292
293 let ab = 'regwrite'
294 call setreg('=', '')
295 call setreg('=', 'a', 'a')
296 call setreg('=', 'b', 'a')
297 call assert_equal('regwrite', getreg('='))
298
Bram Moolenaar4b96df52020-01-26 22:00:26 +0100299 " Test for setting a list of lines to special registers
Bram Moolenaar6f1f0ca2019-12-01 18:16:18 +0100300 call setreg('/', [])
301 call assert_equal('', @/)
302 call setreg('=', [])
303 call assert_equal('', @=)
304 call assert_fails("call setreg('/', ['a', 'b'])", 'E883:')
305 call assert_fails("call setreg('=', ['a', 'b'])", 'E883:')
306 call assert_equal(0, setreg('_', ['a', 'b']))
307
308 " Test for recording to a invalid register
309 call assert_beeps('normal q$')
310
311 " Appending to a register when recording
312 call append(0, "text for clipboard test")
313 normal gg
314 call feedkeys('qrllq', 'xt')
315 call feedkeys('qRhhq', 'xt')
316 call assert_equal('llhh', getreg('r'))
317
Bram Moolenaar54c8d222019-12-02 20:41:39 +0100318 " Appending a list of characters to a register from different lines
319 let @r = ''
320 call append(0, ['abcdef', '123456'])
321 normal gg"ry3l
322 call cursor(2, 4)
323 normal "Ry3l
324 call assert_equal('abc456', @r)
325
326 " Test for gP with multiple lines selected using characterwise motion
327 %delete
328 call append(0, ['vim editor', 'vim editor'])
329 let @r = ''
330 exe "normal ggwy/vim /e\<CR>gP"
331 call assert_equal(['vim editor', 'vim editor', 'vim editor'], getline(1, 3))
332
333 " Test for gP with . register
334 %delete
335 normal iabc
336 normal ".gp
337 call assert_equal('abcabc', getline(1))
338 normal 0".gP
339 call assert_equal('abcabcabc', getline(1))
340
Bram Moolenaar0e05de42020-03-25 22:23:46 +0100341 let @"=''
342 call setreg('', '1')
343 call assert_equal('1', @")
344 call setreg('@', '2')
345 call assert_equal('2', @")
346
Bram Moolenaar71136db2019-11-30 19:48:46 +0100347 enew!
348endfunc
349
Bram Moolenaar54c8d222019-12-02 20:41:39 +0100350" Test for clipboard registers (* and +)
351func Test_clipboard_regs()
352 CheckNotGui
353 CheckFeature clipboard_working
354
355 new
356 call append(0, "text for clipboard test")
357 normal gg"*yiw
358 call assert_equal('text', getreg('*'))
359 normal gg2w"+yiw
360 call assert_equal('clipboard', getreg('+'))
361
362 " Test for replacing the clipboard register contents
363 set clipboard=unnamed
364 let @* = 'food'
365 normal ggviw"*p
366 call assert_equal('text', getreg('*'))
367 call assert_equal('food for clipboard test', getline(1))
368 normal ggviw"*p
369 call assert_equal('food', getreg('*'))
370 call assert_equal('text for clipboard test', getline(1))
371
372 " Test for replacing the selection register contents
373 set clipboard=unnamedplus
374 let @+ = 'food'
375 normal ggviw"+p
376 call assert_equal('text', getreg('+'))
377 call assert_equal('food for clipboard test', getline(1))
378 normal ggviw"+p
379 call assert_equal('food', getreg('+'))
380 call assert_equal('text for clipboard test', getline(1))
381
382 " Test for auto copying visually selected text to clipboard register
383 call setline(1, "text for clipboard test")
384 let @* = ''
385 set clipboard=autoselect
386 normal ggwwviwy
387 call assert_equal('clipboard', @*)
388
389 " Test for auto copying visually selected text to selection register
390 let @+ = ''
391 set clipboard=autoselectplus
392 normal ggwviwy
393 call assert_equal('for', @+)
394
395 set clipboard&vim
396 bwipe!
397endfunc
398
399" Test for restarting the current mode (insert or virtual replace) after
400" executing the contents of a register
401func Test_put_reg_restart_mode()
402 new
403 call append(0, 'editor')
404 normal gg
405 let @r = "ivim \<Esc>"
406 call feedkeys("i\<C-O>@r\<C-R>=mode()\<CR>", 'xt')
407 call assert_equal('vimi editor', getline(1))
408
409 call setline(1, 'editor')
410 normal gg
411 call feedkeys("gR\<C-O>@r\<C-R>=mode()\<CR>", 'xt')
412 call assert_equal('vimReditor', getline(1))
413
414 bwipe!
415endfunc
416
Bram Moolenaarbc2b71d2020-02-17 21:33:30 +0100417" Test for executing a register using :@ command
418func Test_execute_register()
419 call setreg('r', [])
420 call assert_beeps('@r')
421 let i = 1
422 let @q = 'let i+= 1'
423 @q
424 @
425 call assert_equal(3, i)
Bram Moolenaar1671f442020-03-10 07:48:13 +0100426
427 " cannot execute a register in operator pending mode
428 call assert_beeps('normal! c@r')
Bram Moolenaarbc2b71d2020-02-17 21:33:30 +0100429endfunc
430
Bram Moolenaarbb861e22020-06-07 18:16:36 +0200431" Test for getting register info
432func Test_get_reginfo()
433 enew
434 call setline(1, ['foo', 'bar'])
435
436 exe 'norm! "zyy'
437 let info = getreginfo('"')
438 call assert_equal('z', info.points_to)
439 call setreg('y', 'baz')
440 call assert_equal('z', getreginfo('').points_to)
441 call setreg('y', { 'isunnamed': v:true })
442 call assert_equal('y', getreginfo('"').points_to)
443
444 exe '$put'
445 call assert_equal(getreg('y'), getline(3))
446 call setreg('', 'qux')
447 call assert_equal('0', getreginfo('').points_to)
448 call setreg('x', 'quux')
449 call assert_equal('0', getreginfo('').points_to)
450
451 let info = getreginfo('')
452 call assert_equal(getreg('', 1, 1), info.regcontents)
453 call assert_equal(getregtype(''), info.regtype)
454
455 exe "norm! 0\<c-v>e" .. '"zy'
456 let info = getreginfo('z')
457 call assert_equal(getreg('z', 1, 1), info.regcontents)
458 call assert_equal(getregtype('z'), info.regtype)
459 call assert_equal(1, +info.isunnamed)
460
461 let info = getreginfo('"')
462 call assert_equal('z', info.points_to)
463
464 bwipe!
465endfunc
466
467" Test for restoring register with dict from getreginfo
468func Test_set_register_dict()
469 enew!
470
471 call setreg('"', #{ regcontents: ['one', 'two'],
472 \ regtype: 'V', points_to: 'z' })
473 call assert_equal(['one', 'two'], getreg('"', 1, 1))
474 let info = getreginfo('"')
475 call assert_equal('z', info.points_to)
476 call assert_equal('V', info.regtype)
477 call assert_equal(1, +getreginfo('z').isunnamed)
478
479 call setreg('x', #{ regcontents: ['three', 'four'],
480 \ regtype: 'v', isunnamed: v:true })
481 call assert_equal(['three', 'four'], getreg('"', 1, 1))
482 let info = getreginfo('"')
483 call assert_equal('x', info.points_to)
484 call assert_equal('v', info.regtype)
485 call assert_equal(1, +getreginfo('x').isunnamed)
486
487 call setreg('y', #{ regcontents: 'five',
488 \ regtype: "\<c-v>", isunnamed: v:false })
489 call assert_equal("\<c-v>4", getreginfo('y').regtype)
490 call assert_equal(0, +getreginfo('y').isunnamed)
491 call assert_equal(['three', 'four'], getreg('"', 1, 1))
492 call assert_equal('x', getreginfo('"').points_to)
493
494 call setreg('"', #{ regcontents: 'six' })
495 call assert_equal('0', getreginfo('"').points_to)
496 call assert_equal(1, +getreginfo('0').isunnamed)
497 call assert_equal(['six'], getreginfo('0').regcontents)
498 call assert_equal(['six'], getreginfo('"').regcontents)
499
Bram Moolenaar7633fe52020-06-22 19:10:56 +0200500 let @x = 'one'
501 call setreg('x', {})
502 call assert_equal(1, len(split(execute('reg x'), '\n')))
503
504 call assert_fails("call setreg('0', #{regtype: 'V'}, 'v')", 'E118:')
505 call assert_fails("call setreg('0', #{regtype: 'X'})", 'E475:')
506 call assert_fails("call setreg('0', #{regtype: 'vy'})", 'E475:')
507
Bram Moolenaarbb861e22020-06-07 18:16:36 +0200508 bwipe!
509endfunc
510
Bram Moolenaarcc613032020-06-07 21:31:18 +0200511func Test_v_register()
512 enew
513 call setline(1, 'nothing')
514
515 func s:Put()
516 let s:register = v:register
517 exec 'normal! "' .. v:register .. 'P'
518 endfunc
519 nnoremap <buffer> <plug>(test) :<c-u>call s:Put()<cr>
520 nmap <buffer> S <plug>(test)
521
522 let @z = "testz\n"
523 let @" = "test@\n"
524
525 let s:register = ''
526 call feedkeys('"_ddS', 'mx')
527 call assert_equal('test@', getline('.')) " fails before 8.2.0929
528 call assert_equal('"', s:register) " fails before 8.2.0929
529
530 let s:register = ''
531 call feedkeys('"zS', 'mx')
532 call assert_equal('z', s:register)
533
534 let s:register = ''
535 call feedkeys('"zSS', 'mx')
536 call assert_equal('"', s:register)
537
538 let s:register = ''
539 call feedkeys('"_S', 'mx')
540 call assert_equal('_', s:register)
541
542 let s:register = ''
543 normal "_ddS
544 call assert_equal('"', s:register) " fails before 8.2.0929
545 call assert_equal('test@', getline('.')) " fails before 8.2.0929
546
547 let s:register = ''
548 execute 'normal "z:call' "s:Put()\n"
549 call assert_equal('z', s:register)
550 call assert_equal('testz', getline('.'))
551
552 " Test operator and omap
553 let @b = 'testb'
554 func s:OpFunc(...)
555 let s:register2 = v:register
556 endfunc
557 set opfunc=s:OpFunc
558
559 normal "bg@l
560 normal S
561 call assert_equal('"', s:register) " fails before 8.2.0929
562 call assert_equal('b', s:register2)
563
564 func s:Motion()
565 let s:register1 = v:register
566 normal! l
567 endfunc
568 onoremap <buffer> Q :<c-u>call s:Motion()<cr>
569
570 normal "bg@Q
571 normal S
572 call assert_equal('"', s:register)
573 call assert_equal('b', s:register1)
574 call assert_equal('"', s:register2)
575
576 set opfunc&
577 bwipe!
578endfunc
579
Bram Moolenaar856c1112020-06-17 21:47:23 +0200580" Test for executing the contents of a register as an Ex command with line
581" continuation.
582func Test_execute_reg_as_ex_cmd()
583 " Line continuation with just two lines
584 let code =<< trim END
585 let l = [
586 \ 1]
587 END
588 let @r = code->join("\n")
589 let l = []
590 @r
591 call assert_equal([1], l)
592
593 " Line continuation with more than two lines
594 let code =<< trim END
595 let l = [
596 \ 1,
597 \ 2,
598 \ 3]
599 END
600 let @r = code->join("\n")
601 let l = []
602 @r
603 call assert_equal([1, 2, 3], l)
604
605 " use comments interspersed with code
606 let code =<< trim END
607 let l = [
608 "\ one
609 \ 1,
610 "\ two
611 \ 2,
612 "\ three
613 \ 3]
614 END
615 let @r = code->join("\n")
616 let l = []
617 @r
618 call assert_equal([1, 2, 3], l)
619
620 " use line continuation in the middle
621 let code =<< trim END
622 let a = "one"
623 let l = [
624 \ 1,
625 \ 2]
626 let b = "two"
627 END
628 let @r = code->join("\n")
629 let l = []
630 @r
631 call assert_equal([1, 2], l)
632 call assert_equal("one", a)
633 call assert_equal("two", b)
634
635 " only one line with a \
636 let @r = "\\let l = 1"
637 call assert_fails('@r', 'E10:')
638
639 " only one line with a "\
640 let @r = ' "\ let i = 1'
641 @r
642 call assert_false(exists('i'))
643
644 " first line also begins with a \
645 let @r = "\\let l = [\n\\ 1]"
646 call assert_fails('@r', 'E10:')
647
648 " Test with a large number of lines
649 let @r = "let str = \n"
650 let @r ..= repeat(" \\ 'abcdefghijklmnopqrstuvwxyz' ..\n", 312)
651 let @r ..= ' \ ""'
652 @r
653 call assert_equal(repeat('abcdefghijklmnopqrstuvwxyz', 312), str)
654endfunc
655
Bram Moolenaar25fd2672020-06-22 20:30:27 +0200656" Test for clipboard registers with ASCII NUL
657func Test_clipboard_nul()
658 CheckFeature clipboard_working
659 new
660
661 " Test for putting ASCII NUL into the clipboard
662 set clipboard=unnamed
663 call append(0, "\ntest")
664 normal ggyyp
665 call assert_equal("^@test^@", strtrans(getreg('*')))
666 call assert_equal(getline(1), getline(2))
667 let b = split(execute(":reg *"), "\n")
668 call assert_match('"\*\s*\^@test\^J',b[1])
669
670 set clipboard&vim
671 bwipe!
672endfunc
673
Bram Moolenaaref85a9b2020-07-10 20:24:07 +0200674func Test_ve_blockpaste()
675 new
676 set ve=all
677 0put =['QWERTZ','ASDFGH']
678 call cursor(1,1)
679 exe ":norm! \<C-V>3ljdP"
680 call assert_equal(1, col('.'))
681 call assert_equal(getline(1, 2), ['QWERTZ', 'ASDFGH'])
682 call cursor(1,1)
683 exe ":norm! \<C-V>3ljd"
684 call cursor(1,1)
685 norm! $3lP
686 call assert_equal(5, col('.'))
687 call assert_equal(getline(1, 2), ['TZ QWER', 'GH ASDF'])
688 set ve&vim
689 bwipe!
690endfunc
691
Bram Moolenaar71136db2019-11-30 19:48:46 +0100692" vim: shiftwidth=2 sts=2 expandtab