forked from aniani/vim
patch 8.2.0655: search code not sufficiently tested
Problem: Search code not sufficiently tested. Solution: Add more tests. (Yegappan Lakshmanan, closes #5999)
This commit is contained in:
@@ -1451,11 +1451,27 @@ func Test_normal28_parenthesis()
|
||||
norm! $d(
|
||||
call assert_equal(['With some sentences!', '', ' ', '', 'This is a long sentence', ''], getline(1, '$'))
|
||||
|
||||
" Move to the next sentence from a paragraph macro
|
||||
%d
|
||||
call setline(1, ['.LP', 'blue sky!. blue sky.', 'blue sky. blue sky.'])
|
||||
call cursor(1, 1)
|
||||
normal )
|
||||
call assert_equal([2, 1], [line('.'), col('.')])
|
||||
normal )
|
||||
call assert_equal([2, 12], [line('.'), col('.')])
|
||||
normal ((
|
||||
call assert_equal([1, 1], [line('.'), col('.')])
|
||||
|
||||
" It is an error if a next sentence is not found
|
||||
%d
|
||||
call setline(1, '.SH')
|
||||
call assert_beeps('normal )')
|
||||
|
||||
" If only dot is present, don't treat that as a sentence
|
||||
call setline(1, '. This is a sentence.')
|
||||
normal $((
|
||||
call assert_equal(3, col('.'))
|
||||
|
||||
" Jumping to a fold should open the fold
|
||||
call setline(1, ['', '', 'one', 'two', 'three'])
|
||||
set foldenable
|
||||
@@ -2334,92 +2350,6 @@ func Test_normal42_halfpage()
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
" Tests for text object aw
|
||||
func Test_normal43_textobject1()
|
||||
new
|
||||
call append(0, ['foobar,eins,foobar', 'foo,zwei,foo '])
|
||||
" diw
|
||||
norm! 1gg0diw
|
||||
call assert_equal([',eins,foobar', 'foo,zwei,foo ', ''], getline(1,'$'))
|
||||
" daw
|
||||
norm! 2ggEdaw
|
||||
call assert_equal([',eins,foobar', 'foo,zwei,', ''], getline(1, '$'))
|
||||
%d
|
||||
call append(0, ["foo\teins\tfoobar", "foo\tzwei\tfoo "])
|
||||
" diW
|
||||
norm! 2ggwd2iW
|
||||
call assert_equal(['foo eins foobar', 'foo foo ', ''], getline(1,'$'))
|
||||
" daW
|
||||
norm! 1ggd2aW
|
||||
call assert_equal(['foobar', 'foo foo ', ''], getline(1,'$'))
|
||||
|
||||
%d
|
||||
call append(0, ["foo\teins\tfoobar", "foo\tzwei\tfoo "])
|
||||
" aw in visual line mode switches to characterwise mode
|
||||
norm! 2gg$Vawd
|
||||
call assert_equal(['foo eins foobar', 'foo zwei foo'], getline(1,'$'))
|
||||
norm! 1gg$Viwd
|
||||
call assert_equal(['foo eins ', 'foo zwei foo'], getline(1,'$'))
|
||||
|
||||
" clean up
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
" Test for is and as text objects
|
||||
func Test_normal44_textobjects2()
|
||||
new
|
||||
call append(0, ['This is a test. With some sentences!', '', 'Even with a question? And one more. And no sentence here'])
|
||||
" Test for dis - does not remove trailing whitespace
|
||||
norm! 1gg0dis
|
||||
call assert_equal([' With some sentences!', '', 'Even with a question? And one more. And no sentence here', ''], getline(1,'$'))
|
||||
" Test for das - removes leading whitespace
|
||||
norm! 3ggf?ldas
|
||||
call assert_equal([' With some sentences!', '', 'Even with a question? And no sentence here', ''], getline(1,'$'))
|
||||
" when used in visual mode, is made characterwise
|
||||
norm! 3gg$Visy
|
||||
call assert_equal('v', visualmode())
|
||||
" reset visualmode()
|
||||
norm! 3ggVy
|
||||
norm! 3gg$Vasy
|
||||
call assert_equal('v', visualmode())
|
||||
" basic testing for textobjects a< and at
|
||||
%d
|
||||
call setline(1, ['<div> ','<a href="foobar" class="foo">xyz</a>',' </div>', ' '])
|
||||
" a<
|
||||
norm! 1gg0da<
|
||||
call assert_equal([' ', '<a href="foobar" class="foo">xyz</a>', ' </div>', ' '], getline(1,'$'))
|
||||
norm! 1pj
|
||||
call assert_equal([' <div>', '<a href="foobar" class="foo">xyz</a>', ' </div>', ' '], getline(1,'$'))
|
||||
" at
|
||||
norm! d2at
|
||||
call assert_equal([' '], getline(1,'$'))
|
||||
%d
|
||||
call setline(1, ['<div> ','<a href="foobar" class="foo">xyz</a>',' </div>', ' '])
|
||||
" i<
|
||||
norm! 1gg0di<
|
||||
call assert_equal(['<> ', '<a href="foobar" class="foo">xyz</a>', ' </div>', ' '], getline(1,'$'))
|
||||
norm! 1Pj
|
||||
call assert_equal(['<div> ', '<a href="foobar" class="foo">xyz</a>', ' </div>', ' '], getline(1,'$'))
|
||||
norm! d2it
|
||||
call assert_equal(['<div></div>',' '], getline(1,'$'))
|
||||
" basic testing for a[ and i[ text object
|
||||
%d
|
||||
call setline(1, [' ', '[', 'one [two]', 'thre', ']'])
|
||||
norm! 3gg0di[
|
||||
call assert_equal([' ', '[', ']'], getline(1,'$'))
|
||||
call setline(1, [' ', '[', 'one [two]', 'thre', ']'])
|
||||
norm! 3gg0ftd2a[
|
||||
call assert_equal([' '], getline(1,'$'))
|
||||
%d
|
||||
" Test for i" when cursor is in front of a quoted object
|
||||
call append(0, 'foo "bar"')
|
||||
norm! 1gg0di"
|
||||
call assert_equal(['foo ""', ''], getline(1,'$'))
|
||||
|
||||
" clean up
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
func Test_normal45_drop()
|
||||
if !has('dnd')
|
||||
" The ~ register does not exist
|
||||
@@ -3065,4 +2995,41 @@ func Test_empty_region_error()
|
||||
close!
|
||||
endfunc
|
||||
|
||||
" Test for 'w' and 'b' commands
|
||||
func Test_normal_word_move()
|
||||
new
|
||||
call setline(1, ['foo bar a', '', 'foo bar b'])
|
||||
" copy a single character word at the end of a line
|
||||
normal 1G$yw
|
||||
call assert_equal('a', @")
|
||||
" copy a single character word at the end of a file
|
||||
normal G$yw
|
||||
call assert_equal('b', @")
|
||||
" check for a word movement handling an empty line properly
|
||||
normal 1G$vwy
|
||||
call assert_equal("a\n\n", @")
|
||||
|
||||
" copy using 'b' command
|
||||
%d
|
||||
" non-empty blank line at the start of file
|
||||
call setline(1, [' ', 'foo bar'])
|
||||
normal 2Gyb
|
||||
call assert_equal(" \n", @")
|
||||
" try to copy backwards from the start of the file
|
||||
call setline(1, ['one two', 'foo bar'])
|
||||
call assert_beeps('normal ggyb')
|
||||
" 'b' command should stop at an empty line
|
||||
call setline(1, ['one two', '', 'foo bar'])
|
||||
normal 3Gyb
|
||||
call assert_equal("\n", @")
|
||||
normal 3Gy2b
|
||||
call assert_equal("two\n", @")
|
||||
" 'b' command should not stop at a non-empty blank line
|
||||
call setline(1, ['one two', ' ', 'foo bar'])
|
||||
normal 3Gyb
|
||||
call assert_equal("two\n ", @")
|
||||
|
||||
close!
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
||||
Reference in New Issue
Block a user