comparison src/testdir/test_visual.vim @ 15462:2c44001e7e13 v8.1.0739

patch 8.1.0739: text objects in not sufficiently tested commit https://github.com/vim/vim/commit/81b1ba4be57b4bfd7e53a6709b4f98758612ef5f Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 13 16:12:40 2019 +0100 patch 8.1.0739: text objects in not sufficiently tested Problem: Text objects in not sufficiently tested. Solution: Add a few more test cases. (Dominique Pelle, closes https://github.com/vim/vim/issues/3795)
author Bram Moolenaar <Bram@vim.org>
date Sun, 13 Jan 2019 16:15:07 +0100
parents bdf5f546eba0
children 2dcaa860e3fc
comparison
equal deleted inserted replaced
15461:7bfa59464de1 15462:2c44001e7e13
272 " clean up 272 " clean up
273 %d_ 273 %d_
274 set bs&vim 274 set bs&vim
275 endfunc 275 endfunc
276 276
277 func Test_Visual_word_textobject()
278 new
279 call setline(1, ['First sentence. Second sentence.'])
280
281 " When start and end of visual area are identical, 'aw' or 'iw' select
282 " the whole word.
283 norm! 1go2fcvawy
284 call assert_equal('Second ', @")
285 norm! 1go2fcviwy
286 call assert_equal('Second', @")
287
288 " When start and end of visual area are not identical, 'aw' or 'iw'
289 " extend the word in direction of the end of the visual area.
290 norm! 1go2fcvlawy
291 call assert_equal('cond ', @")
292 norm! gv2awy
293 call assert_equal('cond sentence.', @")
294
295 norm! 1go2fcvliwy
296 call assert_equal('cond', @")
297 norm! gv2iwy
298 call assert_equal('cond sentence', @")
299
300 " Extend visual area in opposite direction.
301 norm! 1go2fcvhawy
302 call assert_equal(' Sec', @")
303 norm! gv2awy
304 call assert_equal(' sentence. Sec', @")
305
306 norm! 1go2fcvhiwy
307 call assert_equal('Sec', @")
308 norm! gv2iwy
309 call assert_equal('. Sec', @")
310
311 bwipe!
312 endfunc
313
277 func Test_Visual_sentence_textobject() 314 func Test_Visual_sentence_textobject()
278 new 315 new
279 call setline(1, ['First sentence. Second sentence. Third', 'sentence. Fouth sentence']) 316 call setline(1, ['First sentence. Second sentence. Third', 'sentence. Fourth sentence'])
280 317
281 " When start and end of visual area are identical, 'as' or 'is' select 318 " When start and end of visual area are identical, 'as' or 'is' select
282 " the whole sentence. 319 " the whole sentence.
283 norm! 1gofdvasy 320 norm! 1gofdvasy
284 call assert_equal('Second sentence. ', @") 321 call assert_equal('Second sentence. ', @")
312 norm! gvisy 349 norm! gvisy
313 call assert_equal('First sentence. Second', @") 350 call assert_equal('First sentence. Second', @")
314 351
315 bwipe! 352 bwipe!
316 endfunc 353 endfunc
354
355 func Test_Visual_paragraph_textobject()
356 new
357 call setline(1, ['First line.',
358 \ '',
359 \ 'Second line.',
360 \ 'Third line.',
361 \ 'Fourth line.',
362 \ 'Fifth line.',
363 \ '',
364 \ 'Sixth line.'])
365
366 " When start and end of visual area are identical, 'ap' or 'ip' select
367 " the whole paragraph.
368 norm! 4ggvapy
369 call assert_equal("Second line.\nThird line.\nFourth line.\nFifth line.\n\n", @")
370 norm! 4ggvipy
371 call assert_equal("Second line.\nThird line.\nFourth line.\nFifth line.\n", @")
372
373 " When start and end of visual area are not identical, 'ap' or 'ip'
374 " extend the sentence in direction of the end of the visual area.
375 " FIXME: actually, it is not sufficient to have different start and
376 " end of visual selection, the start line and end line have to differ,
377 " which is not consistent with the documentation.
378 norm! 4ggVjapy
379 call assert_equal("Third line.\nFourth line.\nFifth line.\n\n", @")
380 norm! gvapy
381 call assert_equal("Third line.\nFourth line.\nFifth line.\n\nSixth line.\n", @")
382 norm! 4ggVjipy
383 call assert_equal("Third line.\nFourth line.\nFifth line.\n", @")
384 norm! gvipy
385 call assert_equal("Third line.\nFourth line.\nFifth line.\n\n", @")
386 norm! gvipy
387 call assert_equal("Third line.\nFourth line.\nFifth line.\n\nSixth line.\n", @")
388
389 " Extend visual area in opposite direction.
390 norm! 5ggVkapy
391 call assert_equal("\nSecond line.\nThird line.\nFourth line.\n", @")
392 norm! gvapy
393 call assert_equal("First line.\n\nSecond line.\nThird line.\nFourth line.\n", @")
394 norm! 5ggVkipy
395 call assert_equal("Second line.\nThird line.\nFourth line.\n", @")
396 norma gvipy
397 call assert_equal("\nSecond line.\nThird line.\nFourth line.\n", @")
398 norm! gvipy
399 call assert_equal("First line.\n\nSecond line.\nThird line.\nFourth line.\n", @")
400
401 bwipe!
402 endfunc