Mercurial > vim
comparison src/testdir/test_registers.vim @ 18784:7b57a80f70f6 v8.1.2381
patch 8.1.2381: not all register related code is covered by tests
Commit: https://github.com/vim/vim/commit/54c8d229f54e36e89fcd5d84e523fd894d018024
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Dec 2 20:41:39 2019 +0100
patch 8.1.2381: not all register related code is covered by tests
Problem: Not all register related code is covered by tests.
Solution: Add more test cases. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5301)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 02 Dec 2019 20:45:03 +0100 |
parents | 50fde4e20790 |
children | 2ef19eed524a |
comparison
equal
deleted
inserted
replaced
18783:ee76aada926d | 18784:7b57a80f70f6 |
---|---|
1 " | 1 " |
2 " Tests for register operations | 2 " Tests for register operations |
3 " | 3 " |
4 | |
5 source check.vim | |
4 | 6 |
5 " This test must be executed first to check for empty and unset registers. | 7 " This test must be executed first to check for empty and unset registers. |
6 func Test_aaa_empty_reg_test() | 8 func Test_aaa_empty_reg_test() |
7 call assert_fails('normal @@', 'E748:') | 9 call assert_fails('normal @@', 'E748:') |
8 call assert_fails('normal @%', 'E354:') | 10 call assert_fails('normal @%', 'E354:') |
234 call assert_equal('', getreg("\<C-W>")) | 236 call assert_equal('', getreg("\<C-W>")) |
235 call assert_equal('', getreg("\<C-L>")) | 237 call assert_equal('', getreg("\<C-L>")) |
236 | 238 |
237 call assert_equal('', getregtype('!')) | 239 call assert_equal('', getregtype('!')) |
238 | 240 |
239 " Test for clipboard registers (* and +) | |
240 if has("clipboard_working") | |
241 call append(0, "text for clipboard test") | |
242 normal gg"*yiw | |
243 call assert_equal('text', getreg('*')) | |
244 normal gg2w"+yiw | |
245 call assert_equal('clipboard', getreg('+')) | |
246 endif | |
247 | |
248 " Test for inserting an invalid register content | 241 " Test for inserting an invalid register content |
249 call assert_beeps('exe "normal i\<C-R>!"') | 242 call assert_beeps('exe "normal i\<C-R>!"') |
250 | 243 |
251 " Test for inserting a register with multiple lines | 244 " Test for inserting a register with multiple lines |
252 call deletebufline('', 1, '$') | 245 call deletebufline('', 1, '$') |
298 normal gg | 291 normal gg |
299 call feedkeys('qrllq', 'xt') | 292 call feedkeys('qrllq', 'xt') |
300 call feedkeys('qRhhq', 'xt') | 293 call feedkeys('qRhhq', 'xt') |
301 call assert_equal('llhh', getreg('r')) | 294 call assert_equal('llhh', getreg('r')) |
302 | 295 |
296 " Appending a list of characters to a register from different lines | |
297 let @r = '' | |
298 call append(0, ['abcdef', '123456']) | |
299 normal gg"ry3l | |
300 call cursor(2, 4) | |
301 normal "Ry3l | |
302 call assert_equal('abc456', @r) | |
303 | |
304 " Test for gP with multiple lines selected using characterwise motion | |
305 %delete | |
306 call append(0, ['vim editor', 'vim editor']) | |
307 let @r = '' | |
308 exe "normal ggwy/vim /e\<CR>gP" | |
309 call assert_equal(['vim editor', 'vim editor', 'vim editor'], getline(1, 3)) | |
310 | |
311 " Test for gP with . register | |
312 %delete | |
313 normal iabc | |
314 normal ".gp | |
315 call assert_equal('abcabc', getline(1)) | |
316 normal 0".gP | |
317 call assert_equal('abcabcabc', getline(1)) | |
318 | |
303 enew! | 319 enew! |
304 endfunc | 320 endfunc |
305 | 321 |
322 " Test for clipboard registers (* and +) | |
323 func Test_clipboard_regs() | |
324 CheckNotGui | |
325 CheckFeature clipboard_working | |
326 | |
327 new | |
328 call append(0, "text for clipboard test") | |
329 normal gg"*yiw | |
330 call assert_equal('text', getreg('*')) | |
331 normal gg2w"+yiw | |
332 call assert_equal('clipboard', getreg('+')) | |
333 | |
334 " Test for replacing the clipboard register contents | |
335 set clipboard=unnamed | |
336 let @* = 'food' | |
337 normal ggviw"*p | |
338 call assert_equal('text', getreg('*')) | |
339 call assert_equal('food for clipboard test', getline(1)) | |
340 normal ggviw"*p | |
341 call assert_equal('food', getreg('*')) | |
342 call assert_equal('text for clipboard test', getline(1)) | |
343 | |
344 " Test for replacing the selection register contents | |
345 set clipboard=unnamedplus | |
346 let @+ = 'food' | |
347 normal ggviw"+p | |
348 call assert_equal('text', getreg('+')) | |
349 call assert_equal('food for clipboard test', getline(1)) | |
350 normal ggviw"+p | |
351 call assert_equal('food', getreg('+')) | |
352 call assert_equal('text for clipboard test', getline(1)) | |
353 | |
354 " Test for auto copying visually selected text to clipboard register | |
355 call setline(1, "text for clipboard test") | |
356 let @* = '' | |
357 set clipboard=autoselect | |
358 normal ggwwviwy | |
359 call assert_equal('clipboard', @*) | |
360 | |
361 " Test for auto copying visually selected text to selection register | |
362 let @+ = '' | |
363 set clipboard=autoselectplus | |
364 normal ggwviwy | |
365 call assert_equal('for', @+) | |
366 | |
367 set clipboard&vim | |
368 bwipe! | |
369 endfunc | |
370 | |
371 " Test for restarting the current mode (insert or virtual replace) after | |
372 " executing the contents of a register | |
373 func Test_put_reg_restart_mode() | |
374 new | |
375 call append(0, 'editor') | |
376 normal gg | |
377 let @r = "ivim \<Esc>" | |
378 call feedkeys("i\<C-O>@r\<C-R>=mode()\<CR>", 'xt') | |
379 call assert_equal('vimi editor', getline(1)) | |
380 | |
381 call setline(1, 'editor') | |
382 normal gg | |
383 call feedkeys("gR\<C-O>@r\<C-R>=mode()\<CR>", 'xt') | |
384 call assert_equal('vimReditor', getline(1)) | |
385 | |
386 bwipe! | |
387 endfunc | |
388 | |
306 " vim: shiftwidth=2 sts=2 expandtab | 389 " vim: shiftwidth=2 sts=2 expandtab |