• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revision7b57a80f70f6454e1e374678dd2e28f3f3aab888 (tree)
Time2019-12-03 04:45:03
AuthorBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Log Message

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)

Change Summary

Incremental Difference

diff -r ee76aada926d -r 7b57a80f70f6 src/testdir/test_marks.vim
--- a/src/testdir/test_marks.vim Mon Dec 02 08:23:21 2019 +0100
+++ b/src/testdir/test_marks.vim Mon Dec 02 20:45:03 2019 +0100
@@ -174,3 +174,20 @@
174174 call assert_fails('mark xx', 'E488:')
175175 call assert_fails('mark _', 'E191:')
176176 endfunc
177+
178+" Test for :lockmarks when pasting content
179+func Test_lockmarks_with_put()
180+ new
181+ call append(0, repeat(['sky is blue'], 4))
182+ normal gg
183+ 1,2yank r
184+ put r
185+ normal G
186+ lockmarks put r
187+ call assert_equal(2, line("'["))
188+ call assert_equal(3, line("']"))
189+
190+ bwipe!
191+endfunc
192+
193+" vim: shiftwidth=2 sts=2 expandtab
diff -r ee76aada926d -r 7b57a80f70f6 src/testdir/test_registers.vim
--- a/src/testdir/test_registers.vim Mon Dec 02 08:23:21 2019 +0100
+++ b/src/testdir/test_registers.vim Mon Dec 02 20:45:03 2019 +0100
@@ -2,6 +2,8 @@
22 " Tests for register operations
33 "
44
5+source check.vim
6+
57 " This test must be executed first to check for empty and unset registers.
68 func Test_aaa_empty_reg_test()
79 call assert_fails('normal @@', 'E748:')
@@ -236,15 +238,6 @@
236238
237239 call assert_equal('', getregtype('!'))
238240
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-
248241 " Test for inserting an invalid register content
249242 call assert_beeps('exe "normal i\<C-R>!"')
250243
@@ -300,7 +293,97 @@
300293 call feedkeys('qRhhq', 'xt')
301294 call assert_equal('llhh', getreg('r'))
302295
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+
303319 enew!
304320 endfunc
305321
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+
306389 " vim: shiftwidth=2 sts=2 expandtab
diff -r ee76aada926d -r 7b57a80f70f6 src/testdir/test_virtualedit.vim
--- a/src/testdir/test_virtualedit.vim Mon Dec 02 08:23:21 2019 +0100
+++ b/src/testdir/test_virtualedit.vim Mon Dec 02 20:45:03 2019 +0100
@@ -84,43 +84,130 @@
8484 set virtualedit=
8585 endfunc
8686
87-" Test for pasting before and after a tab character
87+" Tests for pasting at the beginning, end and middle of a tab character
88+" in virtual edit mode.
8889 func Test_paste_in_tab()
8990 new
90- let @" = 'xyz'
91+ call append(0, '')
9192 set virtualedit=all
92- call append(0, "a\tb")
93- call cursor(1, 2, 6)
93+
94+ " Tests for pasting a register with characterwise mode type
95+ call setreg('"', 'xyz', 'c')
96+
97+ " paste (p) unnamed register at the beginning of a tab
98+ call setline(1, "a\tb")
99+ call cursor(1, 2, 0)
94100 normal p
95- call assert_equal("a\txyzb", getline(1))
101+ call assert_equal('a xyz b', getline(1))
102+
103+ " paste (P) unnamed register at the beginning of a tab
96104 call setline(1, "a\tb")
97- call cursor(1, 2)
105+ call cursor(1, 2, 0)
98106 normal P
99107 call assert_equal("axyz\tb", getline(1))
100108
101- " Test for virtual block paste
102- call setreg('"', 'xyz', 'b')
109+ " paste (p) unnamed register at the end of a tab
103110 call setline(1, "a\tb")
104111 call cursor(1, 2, 6)
105112 normal p
106113 call assert_equal("a\txyzb", getline(1))
114+
115+ " paste (P) unnamed register at the end of a tab
107116 call setline(1, "a\tb")
108117 call cursor(1, 2, 6)
109118 normal P
110- call assert_equal("a xyz b", getline(1))
119+ call assert_equal('a xyz b', getline(1))
111120
112- " Test for virtual block paste with gp and gP
121+ " Tests for pasting a register with blockwise mode type
122+ call setreg('"', 'xyz', 'b')
123+
124+ " paste (p) unnamed register at the beginning of a tab
125+ call setline(1, "a\tb")
126+ call cursor(1, 2, 0)
127+ normal p
128+ call assert_equal('a xyz b', getline(1))
129+
130+ " paste (P) unnamed register at the beginning of a tab
131+ call setline(1, "a\tb")
132+ call cursor(1, 2, 0)
133+ normal P
134+ call assert_equal("axyz\tb", getline(1))
135+
136+ " paste (p) unnamed register at the end of a tab
137+ call setline(1, "a\tb")
138+ call cursor(1, 2, 6)
139+ normal p
140+ call assert_equal("a\txyzb", getline(1))
141+
142+ " paste (P) unnamed register at the end of a tab
143+ call setline(1, "a\tb")
144+ call cursor(1, 2, 6)
145+ normal P
146+ call assert_equal('a xyz b', getline(1))
147+
148+ " Tests for pasting with gp and gP in virtual edit mode
149+
150+ " paste (gp) unnamed register at the beginning of a tab
151+ call setline(1, "a\tb")
152+ call cursor(1, 2, 0)
153+ normal gp
154+ call assert_equal('a xyz b', getline(1))
155+ call assert_equal([0, 1, 12, 0, 12], getcurpos())
156+
157+ " paste (gP) unnamed register at the beginning of a tab
158+ call setline(1, "a\tb")
159+ call cursor(1, 2, 0)
160+ normal gP
161+ call assert_equal("axyz\tb", getline(1))
162+ call assert_equal([0, 1, 5, 0, 5], getcurpos())
163+
164+ " paste (gp) unnamed register at the end of a tab
113165 call setline(1, "a\tb")
114166 call cursor(1, 2, 6)
115167 normal gp
116168 call assert_equal("a\txyzb", getline(1))
117169 call assert_equal([0, 1, 6, 0, 12], getcurpos())
170+
171+ " paste (gP) unnamed register at the end of a tab
118172 call setline(1, "a\tb")
119173 call cursor(1, 2, 6)
120174 normal gP
121- call assert_equal("a xyz b", getline(1))
122- call assert_equal([0, 1, 12, 0 ,12], getcurpos())
175+ call assert_equal('a xyz b', getline(1))
176+ call assert_equal([0, 1, 12, 0, 12], getcurpos())
177+
178+ " Tests for pasting a named register
179+ let @r = 'xyz'
180+
181+ " paste (gp) named register in the middle of a tab
182+ call setline(1, "a\tb")
183+ call cursor(1, 2, 2)
184+ normal "rgp
185+ call assert_equal('a xyz b', getline(1))
186+ call assert_equal([0, 1, 8, 0, 8], getcurpos())
187+
188+ " paste (gP) named register in the middle of a tab
189+ call setline(1, "a\tb")
190+ call cursor(1, 2, 2)
191+ normal "rgP
192+ call assert_equal('a xyz b', getline(1))
193+ call assert_equal([0, 1, 7, 0, 7], getcurpos())
123194
124195 bwipe!
125196 set virtualedit=
126197 endfunc
198+
199+" Test for yanking a few spaces within a tab to a register
200+func Test_yank_in_tab()
201+ new
202+ let @r = ''
203+ call setline(1, "a\tb")
204+ set virtualedit=all
205+ call cursor(1, 2, 2)
206+ normal "ry5l
207+ call assert_equal(' ', @r)
208+
209+ bwipe!
210+ set virtualedit=
211+endfunc
212+
213+" vim: shiftwidth=2 sts=2 expandtab
diff -r ee76aada926d -r 7b57a80f70f6 src/version.c
--- a/src/version.c Mon Dec 02 08:23:21 2019 +0100
+++ b/src/version.c Mon Dec 02 20:45:03 2019 +0100
@@ -743,6 +743,8 @@
743743 static int included_patches[] =
744744 { /* Add new patch number below this line */
745745 /**/
746+ 2381,
747+/**/
746748 2380,
747749 /**/
748750 2379,
Show on old repository browser