@@ -99,47 +99,40 @@ function! s:test_on_normal_mode(type, cases)
9999 endfor
100100endfunction
101101
102- function ! s: test_on_visual_mode_basic (type , cases)
102+ function ! s: test_on_visual_mode (type , cases, variant )
103103 for [il , ic , c , d , ebl, ebc, eel, eec, eyanked] in a: cases
104104 call cursor (il , ic )
105105 Expect [il , ic ] == getpos (' .' )[1 :2 ]
106- execute ' silent! normal' printf (" v%s[%s%s]\<Esc> " , c ? c : ' ' , a: type , d )
107- let [_, al , ac, _] = getpos (' .' )
108- let el = d = ~# ' [pP]' ? ebl : eel
109- let ec = d = ~# ' [pP]' ? ebc : eec
110- Expect [il , ic , c , d , al , ac] == [il , ic , c , d , el , ec ]
111- endfor
112- endfunction
113-
114- function ! s: test_on_visual_mode_kept (type , cases)
115- for [il , ic , c , d , ebl, ebc, eel, eec, eyanked] in a: cases
116- call cursor (il , ic )
117- Expect [il , ic ] == getpos (' .' )[1 :2 ]
118- let @0 = ' some random string'
119- " If Visual mode is not kept by the move command, nothing is yanked.
120- execute ' silent! normal' printf (" v%s[%s%s]y" , c ? c : ' ' , a: type , d )
121- let [vbl, vbc] = getpos (" '<" )[1 :2 ]
122- let [vel, vec] = getpos (" '>" )[1 :2 ]
123- Expect [vbl, vbc] == getpos (' .' )[1 :2 ]
124- Expect [il , ic , c , d , vbl, vbc, vel, vec, @0 ] == [il , ic , c , d , ebl, ebc, eel, eec, eyanked]
125- endfor
126- endfunction
127106
128- function ! s: test_on_visual_mode_manually_repeated (type , cases)
129- for [il , ic , c , d , ebl, ebc, eel, eec, eyanked] in a: cases
130- call cursor (il , ic )
131- Expect [il , ic ] == getpos (' .' )[1 :2 ]
132- let @0 = ' some random string'
133- " If Visual mode is not kept by the move command, nothing is yanked.
134- silent ! normal ! v
135- for i in range (c )
136- execute ' silent! normal' printf (" [%s%s]" , a: type , d )
137- endfor
138- silent ! normal ! y
139- let [vbl, vbc] = getpos (" '<" )[1 :2 ]
140- let [vel, vec] = getpos (" '>" )[1 :2 ]
141- Expect [vbl, vbc] == getpos (' .' )[1 :2 ]
142- Expect [il , ic , c , d , vbl, vbc, vel, vec, @0 ] == [il , ic , c , d , ebl, ebc, eel, eec, eyanked]
107+ if a: variant == # ' basic'
108+ execute ' silent! normal' printf (" v%s[%s%s]\<Esc> " , c ? c : ' ' , a: type , d )
109+ let [_, al , ac, _] = getpos (' .' )
110+ let el = d = ~# ' [pP]' ? ebl : eel
111+ let ec = d = ~# ' [pP]' ? ebc : eec
112+ Expect [a: variant , il , ic , c , d , al , ac] == [a: variant , il , ic , c , d , el , ec ]
113+ elseif a: variant == # ' kept'
114+ let @0 = ' some random string'
115+ " If Visual mode is not kept by the move command, nothing is yanked.
116+ execute ' silent! normal' printf (" v%s[%s%s]y" , c ? c : ' ' , a: type , d )
117+ let [vbl, vbc] = getpos (" '<" )[1 :2 ]
118+ let [vel, vec] = getpos (" '>" )[1 :2 ]
119+ Expect [vbl, vbc] == getpos (' .' )[1 :2 ]
120+ Expect [a: variant , il , ic , c , d , vbl, vbc, vel, vec, @0 ] == [a: variant , il , ic , c , d , ebl, ebc, eel, eec, eyanked]
121+ elseif a: variant == # ' manually_repeated'
122+ let @0 = ' some random string'
123+ " If Visual mode is not kept by the move command, nothing is yanked.
124+ silent ! normal ! v
125+ for i in range (c )
126+ execute ' silent! normal' printf (" [%s%s]" , a: type , d )
127+ endfor
128+ silent ! normal ! y
129+ let [vbl, vbc] = getpos (" '<" )[1 :2 ]
130+ let [vel, vec] = getpos (" '>" )[1 :2 ]
131+ Expect [vbl, vbc] == getpos (' .' )[1 :2 ]
132+ Expect [a: variant , il , ic , c , d , vbl, vbc, vel, vec, @0 ] == [a: variant , il , ic , c , d , ebl, ebc, eel, eec, eyanked]
133+ else
134+ throw ' unreachable'
135+ endif
143136 endfor
144137endfunction
145138
@@ -245,9 +238,9 @@ describe '"move-*"'
245238 end
246239
247240 it ' works in Visual mode'
248- call s: test_on_visual_mode_basic (' p' , s: cases )
249- call s: test_on_visual_mode_kept (' p' , s: cases )
250- call s: test_on_visual_mode_manually_repeated (' p' , s: cases )
241+ call s: test_on_visual_mode (' p' , s: cases, ' basic ' )
242+ call s: test_on_visual_mode (' p' , s: cases, ' kept ' )
243+ call s: test_on_visual_mode (' p' , s: cases, ' manually_repeated ' )
251244 end
252245
253246 it ' works in Operator-pending mode'
@@ -261,9 +254,9 @@ describe '"move-*"'
261254 end
262255
263256 it ' works in Visual mode'
264- call s: test_on_visual_mode_basic (' f' , s: cases )
265- call s: test_on_visual_mode_kept (' f' , s: cases )
266- call s: test_on_visual_mode_manually_repeated (' f' , s: cases )
257+ call s: test_on_visual_mode (' f' , s: cases, ' basic ' )
258+ call s: test_on_visual_mode (' f' , s: cases, ' kept ' )
259+ call s: test_on_visual_mode (' f' , s: cases, ' manually_repeated ' )
267260 end
268261
269262 it ' works in Operator-pending mode'
0 commit comments