comparison src/testdir/test_virtualedit.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 f966b20bb74d
comparison
equal deleted inserted replaced
18783:ee76aada926d 18784:7b57a80f70f6
82 call assert_equal('x', getline(1)) 82 call assert_equal('x', getline(1))
83 bwipe! 83 bwipe!
84 set virtualedit= 84 set virtualedit=
85 endfunc 85 endfunc
86 86
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.
88 func Test_paste_in_tab() 89 func Test_paste_in_tab()
89 new 90 new
90 let @" = 'xyz' 91 call append(0, '')
91 set virtualedit=all 92 set virtualedit=all
92 call append(0, "a\tb") 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)
100 normal p
101 call assert_equal('a xyz b', getline(1))
102
103 " paste (P) unnamed register at the beginning of a tab
104 call setline(1, "a\tb")
105 call cursor(1, 2, 0)
106 normal P
107 call assert_equal("axyz\tb", getline(1))
108
109 " paste (p) unnamed register at the end of a tab
110 call setline(1, "a\tb")
93 call cursor(1, 2, 6) 111 call cursor(1, 2, 6)
94 normal p 112 normal p
95 call assert_equal("a\txyzb", getline(1)) 113 call assert_equal("a\txyzb", getline(1))
96 call setline(1, "a\tb") 114
97 call cursor(1, 2) 115 " paste (P) unnamed register at the end of a tab
116 call setline(1, "a\tb")
117 call cursor(1, 2, 6)
118 normal P
119 call assert_equal('a xyz b', getline(1))
120
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)
98 normal P 133 normal P
99 call assert_equal("axyz\tb", getline(1)) 134 call assert_equal("axyz\tb", getline(1))
100 135
101 " Test for virtual block paste 136 " paste (p) unnamed register at the end of a tab
102 call setreg('"', 'xyz', 'b')
103 call setline(1, "a\tb") 137 call setline(1, "a\tb")
104 call cursor(1, 2, 6) 138 call cursor(1, 2, 6)
105 normal p 139 normal p
106 call assert_equal("a\txyzb", getline(1)) 140 call assert_equal("a\txyzb", getline(1))
107 call setline(1, "a\tb") 141
108 call cursor(1, 2, 6) 142 " paste (P) unnamed register at the end of a tab
109 normal P 143 call setline(1, "a\tb")
110 call assert_equal("a xyz b", getline(1)) 144 call cursor(1, 2, 6)
111 145 normal P
112 " Test for virtual block paste with gp and gP 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
113 call setline(1, "a\tb") 165 call setline(1, "a\tb")
114 call cursor(1, 2, 6) 166 call cursor(1, 2, 6)
115 normal gp 167 normal gp
116 call assert_equal("a\txyzb", getline(1)) 168 call assert_equal("a\txyzb", getline(1))
117 call assert_equal([0, 1, 6, 0, 12], getcurpos()) 169 call assert_equal([0, 1, 6, 0, 12], getcurpos())
170
171 " paste (gP) unnamed register at the end of a tab
118 call setline(1, "a\tb") 172 call setline(1, "a\tb")
119 call cursor(1, 2, 6) 173 call cursor(1, 2, 6)
120 normal gP 174 normal gP
121 call assert_equal("a xyz b", getline(1)) 175 call assert_equal('a xyz b', getline(1))
122 call assert_equal([0, 1, 12, 0 ,12], getcurpos()) 176 call assert_equal([0, 1, 12, 0, 12], getcurpos())
123 177
124 bwipe! 178 " Tests for pasting a named register
125 set virtualedit= 179 let @r = 'xyz'
126 endfunc 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())
194
195 bwipe!
196 set virtualedit=
197 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