mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #19402 from zeertzjq/vim-8.2.0655
vim-patch:8.2.{0655,1040}: not enough tests
This commit is contained in:
@@ -29,6 +29,17 @@ func Test_charsearch()
|
||||
set cpo-=;
|
||||
normal! ;;p
|
||||
call assert_equal('ZabcdeZfghijkZZemnokqretkZvwxyz', getline(3))
|
||||
|
||||
" check that repeating a search before and after a line fails
|
||||
normal 3Gfv
|
||||
call assert_beeps('normal ;')
|
||||
call assert_beeps('normal ,')
|
||||
|
||||
" clear the character search
|
||||
call setcharsearch({'char' : ''})
|
||||
call assert_equal('', getcharsearch().char)
|
||||
|
||||
call assert_fails("call setcharsearch([])", 'E715:')
|
||||
enew!
|
||||
endfunc
|
||||
|
||||
@@ -73,4 +84,18 @@ func Test_csearch_virtualedit()
|
||||
close!
|
||||
endfunc
|
||||
|
||||
" Test for character search failure in latin1 encoding
|
||||
func Test_charsearch_latin1()
|
||||
new
|
||||
let save_enc = &encoding
|
||||
" set encoding=latin1
|
||||
call setline(1, 'abcdefghijk')
|
||||
call assert_beeps('normal fz')
|
||||
call assert_beeps('normal tx')
|
||||
call assert_beeps('normal $Fz')
|
||||
call assert_beeps('normal $Tx')
|
||||
let &encoding = save_enc
|
||||
close!
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
||||
@@ -99,6 +99,7 @@ func Test_screenpos()
|
||||
\ 'curscol': wincol + 9,
|
||||
\ 'endcol': wincol + 9}, screenpos(winid, 2, 22))
|
||||
close
|
||||
call assert_equal({}, screenpos(999, 1, 1))
|
||||
bwipe!
|
||||
|
||||
call assert_equal({'col': 1, 'row': 1, 'endcol': 1, 'curscol': 1}, screenpos(win_getid(), 1, 1))
|
||||
|
||||
@@ -185,7 +185,9 @@ func Test_str2nr()
|
||||
|
||||
call assert_fails('call str2nr([])', 'E730:')
|
||||
call assert_fails('call str2nr({->2})', 'E729:')
|
||||
call assert_fails('call str2nr(1.2)', 'E806:')
|
||||
if has('float')
|
||||
call assert_fails('call str2nr(1.2)', 'E806:')
|
||||
endif
|
||||
call assert_fails('call str2nr(10, [])', 'E474:')
|
||||
endfunc
|
||||
|
||||
@@ -325,11 +327,18 @@ func Test_simplify()
|
||||
call assert_equal('./file', simplify('./dir/../file'))
|
||||
call assert_equal('../dir/file', simplify('dir/../../dir/file'))
|
||||
call assert_equal('./file', simplify('dir/.././file'))
|
||||
call assert_equal('../dir', simplify('./../dir'))
|
||||
call assert_equal('..', simplify('../testdir/..'))
|
||||
call mkdir('Xdir')
|
||||
call assert_equal('.', simplify('Xdir/../.'))
|
||||
call delete('Xdir', 'd')
|
||||
|
||||
call assert_fails('call simplify({->0})', 'E729:')
|
||||
call assert_fails('call simplify([])', 'E730:')
|
||||
call assert_fails('call simplify({})', 'E731:')
|
||||
call assert_fails('call simplify(1.2)', 'E806:')
|
||||
if has('float')
|
||||
call assert_fails('call simplify(1.2)', 'E806:')
|
||||
endif
|
||||
endfunc
|
||||
|
||||
func Test_pathshorten()
|
||||
|
||||
@@ -35,6 +35,13 @@ func Test_gf_url()
|
||||
call search("URL")
|
||||
call assert_equal("URL://machine.name:1234?q=vim", expand("<cfile>"))
|
||||
|
||||
%d
|
||||
call setline(1, "demo://remote_file")
|
||||
wincmd f
|
||||
call assert_equal('demo://remote_file', @%)
|
||||
call assert_equal(2, winnr('$'))
|
||||
close!
|
||||
|
||||
set isf&vim
|
||||
enew!
|
||||
endfunc
|
||||
@@ -170,4 +177,21 @@ func Test_gf_error()
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
" If a file is not found by 'gf', then 'includeexpr' should be used to locate
|
||||
" the file.
|
||||
func Test_gf_includeexpr()
|
||||
new
|
||||
let g:Inc_fname = ''
|
||||
func IncFunc()
|
||||
let g:Inc_fname = v:fname
|
||||
return v:fname
|
||||
endfunc
|
||||
setlocal includeexpr=IncFunc()
|
||||
call setline(1, 'somefile.java')
|
||||
call assert_fails('normal gf', 'E447:')
|
||||
call assert_equal('somefile.java', g:Inc_fname)
|
||||
close!
|
||||
delfunc IncFunc
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
||||
@@ -154,8 +154,24 @@ func Test_gn_command()
|
||||
norm! gg0f2vf7gNd
|
||||
call assert_equal(['1678'], getline(1,'$'))
|
||||
sil! %d _
|
||||
|
||||
set wrapscan&vim
|
||||
|
||||
" Without 'wrapscan', in visual mode, running gn without a match should fail
|
||||
" but the visual mode should be kept.
|
||||
set nowrapscan
|
||||
call setline('.', 'one two')
|
||||
let @/ = 'one'
|
||||
call assert_beeps('normal 0wvlgn')
|
||||
exe "normal y"
|
||||
call assert_equal('tw', @")
|
||||
|
||||
" with exclusive selection, run gn and gN
|
||||
set selection=exclusive
|
||||
normal 0gny
|
||||
call assert_equal('one', @")
|
||||
normal 0wgNy
|
||||
call assert_equal('one', @")
|
||||
set selection&
|
||||
endfunc
|
||||
|
||||
func Test_gN_repeat()
|
||||
|
||||
@@ -334,21 +334,24 @@ endfunc
|
||||
|
||||
func Test_motion_if_elif_else_endif()
|
||||
new
|
||||
a
|
||||
/* Test pressing % on #if, #else #elsif and #endif,
|
||||
* with nested #if
|
||||
*/
|
||||
#if FOO
|
||||
/* ... */
|
||||
# if BAR
|
||||
/* ... */
|
||||
# endif
|
||||
#elif BAR
|
||||
/* ... */
|
||||
#else
|
||||
/* ... */
|
||||
#endif
|
||||
.
|
||||
let lines =<< trim END
|
||||
/* Test pressing % on #if, #else #elsif and #endif,
|
||||
* with nested #if
|
||||
*/
|
||||
#if FOO
|
||||
/* ... */
|
||||
# if BAR
|
||||
/* ... */
|
||||
# endif
|
||||
#elif BAR
|
||||
/* ... */
|
||||
#else
|
||||
/* ... */
|
||||
#endif
|
||||
|
||||
#define FOO 1
|
||||
END
|
||||
call setline(1, lines)
|
||||
/#if FOO
|
||||
norm %
|
||||
call assert_equal([9, 1], getpos('.')[1:2])
|
||||
@@ -364,6 +367,30 @@ func Test_motion_if_elif_else_endif()
|
||||
norm $%
|
||||
call assert_equal([6, 1], getpos('.')[1:2])
|
||||
|
||||
" Test for [# and ]# command
|
||||
call cursor(5, 1)
|
||||
normal [#
|
||||
call assert_equal([4, 1], getpos('.')[1:2])
|
||||
call cursor(5, 1)
|
||||
normal ]#
|
||||
call assert_equal([9, 1], getpos('.')[1:2])
|
||||
call cursor(10, 1)
|
||||
normal [#
|
||||
call assert_equal([9, 1], getpos('.')[1:2])
|
||||
call cursor(10, 1)
|
||||
normal ]#
|
||||
call assert_equal([11, 1], getpos('.')[1:2])
|
||||
|
||||
" Finding a match before the first line or after the last line should fail
|
||||
normal gg
|
||||
call assert_beeps('normal [#')
|
||||
normal G
|
||||
call assert_beeps('normal ]#')
|
||||
|
||||
" Finding a match for a macro definition (#define) should fail
|
||||
normal G
|
||||
call assert_beeps('normal %')
|
||||
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
@@ -393,3 +420,5 @@ func Test_motion_c_comment()
|
||||
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
||||
@@ -601,6 +601,26 @@ func Test_ins_compl_tag_sft()
|
||||
%bwipe!
|
||||
endfunc
|
||||
|
||||
" Test for completing words following a completed word in a line
|
||||
func Test_complete_wrapscan()
|
||||
" complete words from another buffer
|
||||
new
|
||||
call setline(1, ['one two', 'three four'])
|
||||
new
|
||||
setlocal complete=w
|
||||
call feedkeys("itw\<C-N>\<C-X>\<C-N>\<C-X>\<C-N>\<C-X>\<C-N>", 'xt')
|
||||
call assert_equal('two three four', getline(1))
|
||||
close!
|
||||
" complete words from the current buffer
|
||||
setlocal complete=.
|
||||
%d
|
||||
call setline(1, ['one two', ''])
|
||||
call cursor(2, 1)
|
||||
call feedkeys("ion\<C-N>\<C-X>\<C-N>\<C-X>\<C-N>\<C-X>\<C-N>", 'xt')
|
||||
call assert_equal('one two one two', getline(2))
|
||||
close!
|
||||
endfunc
|
||||
|
||||
" Test for completing special characters
|
||||
func Test_complete_special_chars()
|
||||
new
|
||||
|
||||
@@ -811,8 +811,9 @@ func Test_normal17_z_scroll_hor2()
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
" Test for H, M and L commands with folds
|
||||
func Test_scroll_cmds()
|
||||
" Test for commands that scroll the window horizontally. Test with folds.
|
||||
" H, M, L, CTRL-E, CTRL-Y, CTRL-U, CTRL-D, PageUp, PageDown commands
|
||||
func Test_vert_scroll_cmds()
|
||||
15new
|
||||
call setline(1, range(1, 100))
|
||||
exe "normal! 30ggz\<CR>"
|
||||
@@ -821,6 +822,8 @@ func Test_scroll_cmds()
|
||||
40,43fold
|
||||
46,49fold
|
||||
let h = winheight(0)
|
||||
|
||||
" Test for H, M and L commands
|
||||
" Top of the screen = 30
|
||||
" Folded lines = 9
|
||||
" Bottom of the screen = 30 + h + 9 - 1
|
||||
@@ -828,15 +831,107 @@ func Test_scroll_cmds()
|
||||
call assert_equal(35 + h, line('.'))
|
||||
normal! 4H
|
||||
call assert_equal(33, line('.'))
|
||||
|
||||
" Test for the CTRL-E and CTRL-Y commands with folds
|
||||
%d
|
||||
call setline(1, range(1, 10))
|
||||
3,5fold
|
||||
exe "normal 6G3\<C-E>"
|
||||
call assert_equal(6, line('w0'))
|
||||
exe "normal 2\<C-Y>"
|
||||
call assert_equal(2, line('w0'))
|
||||
|
||||
" Test for CTRL-Y on a folded line
|
||||
%d
|
||||
call setline(1, range(1, 100))
|
||||
exe (h + 2) .. "," .. (h + 4) .. "fold"
|
||||
exe h + 5
|
||||
normal z-
|
||||
exe "normal \<C-Y>\<C-Y>"
|
||||
call assert_equal(h + 1, line('w$'))
|
||||
|
||||
" Using <PageUp> and <PageDown> in an empty buffer should beep
|
||||
%d
|
||||
call assert_beeps('exe "normal \<PageUp>"')
|
||||
call assert_beeps('exe "normal \<C-B>"')
|
||||
call assert_beeps('exe "normal \<PageDown>"')
|
||||
call assert_beeps('exe "normal \<C-F>"')
|
||||
|
||||
" Test for <C-U> and <C-D> with fold
|
||||
%d
|
||||
call setline(1, range(1, 100))
|
||||
10,35fold
|
||||
set scroll=10
|
||||
exe "normal \<C-D>"
|
||||
call assert_equal(36, line('.'))
|
||||
exe "normal \<C-D>"
|
||||
call assert_equal(46, line('.'))
|
||||
exe "normal \<C-U>"
|
||||
call assert_equal(36, line('.'))
|
||||
exe "normal \<C-U>"
|
||||
call assert_equal(10, line('.'))
|
||||
exe "normal \<C-U>"
|
||||
call assert_equal(1, line('.'))
|
||||
set scroll&
|
||||
|
||||
" Test for scrolling to the top of the file with <C-U> and a fold
|
||||
10
|
||||
normal ztL
|
||||
exe "normal \<C-U>\<C-U>"
|
||||
call assert_equal(1, line('w0'))
|
||||
|
||||
" Test for CTRL-D on a folded line
|
||||
%d
|
||||
call setline(1, range(1, 100))
|
||||
50,100fold
|
||||
75
|
||||
normal z-
|
||||
exe "normal \<C-D>"
|
||||
call assert_equal(50, line('.'))
|
||||
call assert_equal(100, line('w$'))
|
||||
normal z.
|
||||
let lnum = winline()
|
||||
exe "normal \<C-D>"
|
||||
call assert_equal(lnum, winline())
|
||||
call assert_equal(50, line('.'))
|
||||
normal zt
|
||||
exe "normal \<C-D>"
|
||||
call assert_equal(50, line('w0'))
|
||||
|
||||
set foldenable&
|
||||
close!
|
||||
endfunc
|
||||
|
||||
" Test for the 'sidescroll' option
|
||||
func Test_sidescroll_opt()
|
||||
new
|
||||
20vnew
|
||||
|
||||
" scroll by 2 characters horizontally
|
||||
set sidescroll=2 nowrap
|
||||
call setline(1, repeat('a', 40))
|
||||
normal g$l
|
||||
call assert_equal(19, screenpos(0, 1, 21).col)
|
||||
normal l
|
||||
call assert_equal(20, screenpos(0, 1, 22).col)
|
||||
normal g0h
|
||||
call assert_equal(2, screenpos(0, 1, 2).col)
|
||||
call assert_equal(20, screenpos(0, 1, 20).col)
|
||||
|
||||
" when 'sidescroll' is 0, cursor positioned at the center
|
||||
set sidescroll=0
|
||||
normal g$l
|
||||
call assert_equal(11, screenpos(0, 1, 21).col)
|
||||
normal g0h
|
||||
call assert_equal(10, screenpos(0, 1, 10).col)
|
||||
|
||||
%bw!
|
||||
set wrap& sidescroll&
|
||||
endfunc
|
||||
|
||||
" basic tests for foldopen/folddelete
|
||||
func Test_normal18_z_fold()
|
||||
" basic tests for foldopen/folddelete
|
||||
if !has("folding")
|
||||
return
|
||||
endif
|
||||
CheckFeature folding
|
||||
call Setup_NewWindow()
|
||||
50
|
||||
setl foldenable fdm=marker foldlevel=5
|
||||
@@ -1566,11 +1661,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
|
||||
@@ -2484,92 +2595,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
|
||||
@@ -3181,6 +3206,79 @@ func Test_normal_colon_op()
|
||||
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
|
||||
|
||||
" Test for 'scrolloff' with a long line that doesn't fit in the screen
|
||||
func Test_normal_scroloff()
|
||||
10new
|
||||
80vnew
|
||||
call setline(1, repeat('a', 1000))
|
||||
set scrolloff=10
|
||||
normal gg10gj
|
||||
call assert_equal(8, winline())
|
||||
normal 10gj
|
||||
call assert_equal(10, winline())
|
||||
normal 10gk
|
||||
call assert_equal(3, winline())
|
||||
set scrolloff&
|
||||
close!
|
||||
endfunc
|
||||
|
||||
" Test for vertical scrolling with CTRL-F and CTRL-B with a long line
|
||||
func Test_normal_vert_scroll_longline()
|
||||
10new
|
||||
80vnew
|
||||
call setline(1, range(1, 10))
|
||||
call append(5, repeat('a', 1000))
|
||||
exe "normal gg\<C-F>"
|
||||
call assert_equal(6, line('.'))
|
||||
exe "normal \<C-F>\<C-F>"
|
||||
call assert_equal(11, line('.'))
|
||||
call assert_equal(1, winline())
|
||||
exe "normal \<C-B>"
|
||||
call assert_equal(10, line('.'))
|
||||
call assert_equal(3, winline())
|
||||
exe "normal \<C-B>\<C-B>"
|
||||
call assert_equal(5, line('.'))
|
||||
call assert_equal(5, winline())
|
||||
close!
|
||||
endfunc
|
||||
|
||||
" Some commands like yy, cc, dd, >>, << and !! accept a count after
|
||||
" typing the first letter of the command.
|
||||
func Test_normal_count_after_operator()
|
||||
|
||||
@@ -466,9 +466,11 @@ func Test_set_one_column()
|
||||
endfunc
|
||||
|
||||
func Test_set_values()
|
||||
" The file is only generated when running "make test" in the src directory.
|
||||
" opt_test.vim is generated from ../optiondefs.h using gen_opt_test.vim
|
||||
if filereadable('opt_test.vim')
|
||||
source opt_test.vim
|
||||
else
|
||||
throw 'Skipped: opt_test.vim does not exist'
|
||||
endif
|
||||
endfunc
|
||||
|
||||
@@ -813,6 +815,37 @@ func Test_opt_boolean()
|
||||
set number&
|
||||
endfunc
|
||||
|
||||
" Test for the 'window' option
|
||||
func Test_window_opt()
|
||||
" Needs only one open widow
|
||||
%bw!
|
||||
call setline(1, range(1, 8))
|
||||
set window=5
|
||||
exe "normal \<C-F>"
|
||||
call assert_equal(4, line('w0'))
|
||||
exe "normal \<C-F>"
|
||||
call assert_equal(7, line('w0'))
|
||||
exe "normal \<C-F>"
|
||||
call assert_equal(8, line('w0'))
|
||||
exe "normal \<C-B>"
|
||||
call assert_equal(5, line('w0'))
|
||||
exe "normal \<C-B>"
|
||||
call assert_equal(2, line('w0'))
|
||||
exe "normal \<C-B>"
|
||||
call assert_equal(1, line('w0'))
|
||||
set window=1
|
||||
exe "normal gg\<C-F>"
|
||||
call assert_equal(2, line('w0'))
|
||||
exe "normal \<C-F>"
|
||||
call assert_equal(3, line('w0'))
|
||||
exe "normal \<C-B>"
|
||||
call assert_equal(2, line('w0'))
|
||||
exe "normal \<C-B>"
|
||||
call assert_equal(1, line('w0'))
|
||||
enew!
|
||||
set window&
|
||||
endfunc
|
||||
|
||||
" Test for the 'winminheight' option
|
||||
func Test_opt_winminheight()
|
||||
only!
|
||||
|
||||
@@ -520,10 +520,10 @@ func Xtest_browse(cchar)
|
||||
call assert_fails('Xprev', 'E553')
|
||||
call assert_fails('Xpfile', 'E553')
|
||||
Xnfile
|
||||
call assert_equal('Xqftestfile2', bufname('%'))
|
||||
call assert_equal('Xqftestfile2', @%)
|
||||
call assert_equal(10, line('.'))
|
||||
Xpfile
|
||||
call assert_equal('Xqftestfile1', bufname('%'))
|
||||
call assert_equal('Xqftestfile1', @%)
|
||||
call assert_equal(6, line('.'))
|
||||
5Xcc
|
||||
call assert_equal(5, g:Xgetlist({'idx':0}).idx)
|
||||
@@ -539,7 +539,7 @@ func Xtest_browse(cchar)
|
||||
call assert_equal(6, g:Xgetlist({'idx':0}).idx)
|
||||
Xlast
|
||||
Xprev
|
||||
call assert_equal('Xqftestfile2', bufname('%'))
|
||||
call assert_equal('Xqftestfile2', @%)
|
||||
call assert_equal(11, line('.'))
|
||||
call assert_fails('Xnext', 'E553')
|
||||
call assert_fails('Xnfile', 'E553')
|
||||
@@ -552,14 +552,14 @@ func Xtest_browse(cchar)
|
||||
endif
|
||||
call assert_equal(6, g:Xgetlist({'idx':0}).idx)
|
||||
Xrewind
|
||||
call assert_equal('Xqftestfile1', bufname('%'))
|
||||
call assert_equal('Xqftestfile1', @%)
|
||||
call assert_equal(5, line('.'))
|
||||
|
||||
10Xnext
|
||||
call assert_equal('Xqftestfile2', bufname('%'))
|
||||
call assert_equal('Xqftestfile2', @%)
|
||||
call assert_equal(11, line('.'))
|
||||
10Xprev
|
||||
call assert_equal('Xqftestfile1', bufname('%'))
|
||||
call assert_equal('Xqftestfile1', @%)
|
||||
call assert_equal(5, line('.'))
|
||||
|
||||
" Jumping to an error from the error window using cc command
|
||||
@@ -570,7 +570,7 @@ func Xtest_browse(cchar)
|
||||
Xopen
|
||||
10Xcc
|
||||
call assert_equal(11, line('.'))
|
||||
call assert_equal('Xqftestfile2', bufname('%'))
|
||||
call assert_equal('Xqftestfile2', @%)
|
||||
Xopen
|
||||
call cursor(2, 1)
|
||||
if a:cchar == 'c'
|
||||
@@ -579,14 +579,14 @@ func Xtest_browse(cchar)
|
||||
.ll
|
||||
endif
|
||||
call assert_equal(6, line('.'))
|
||||
call assert_equal('Xqftestfile1', bufname('%'))
|
||||
call assert_equal('Xqftestfile1', @%)
|
||||
|
||||
" Jumping to an error from the error window (when only the error window is
|
||||
" present)
|
||||
Xopen | only
|
||||
Xlast 1
|
||||
call assert_equal(5, line('.'))
|
||||
call assert_equal('Xqftestfile1', bufname('%'))
|
||||
call assert_equal('Xqftestfile1', @%)
|
||||
|
||||
Xexpr ""
|
||||
call assert_fails('Xnext', 'E42:')
|
||||
@@ -1961,7 +1961,7 @@ func Test_switchbuf()
|
||||
copen | only
|
||||
cfirst
|
||||
call assert_equal(1, tabpagenr())
|
||||
call assert_equal('Xqftestfile1', bufname(''))
|
||||
call assert_equal('Xqftestfile1', @%)
|
||||
|
||||
" If opening a file changes 'switchbuf', then the new value should be
|
||||
" retained.
|
||||
@@ -2777,7 +2777,7 @@ func Test_cwindow_jump()
|
||||
wincmd b
|
||||
cfirst
|
||||
call assert_equal(2, winnr())
|
||||
call assert_equal('F1', bufname(''))
|
||||
call assert_equal('F1', @%)
|
||||
enew | only
|
||||
exe 'sb' bnum
|
||||
exe 'botright sb' bnum
|
||||
@@ -2867,7 +2867,7 @@ func XvimgrepTests(cchar)
|
||||
edit +3 Xtestfile2
|
||||
Xvimgrep +\cemacs+j Xtestfile1
|
||||
let l = g:Xgetlist()
|
||||
call assert_equal('Xtestfile2', bufname(''))
|
||||
call assert_equal('Xtestfile2', @%)
|
||||
call assert_equal('Editor:Emacs EmAcS', l[0].text)
|
||||
|
||||
" Test for unloading a buffer after vimgrep searched the buffer
|
||||
@@ -3536,7 +3536,7 @@ func Xqfjump_tests(cchar)
|
||||
Xopen | only
|
||||
2Xnext
|
||||
call assert_equal(3, g:Xgetlist({'idx' : 0}).idx)
|
||||
call assert_equal('F3', bufname('%'))
|
||||
call assert_equal('F3', @%)
|
||||
Xnext
|
||||
call assert_equal(7, col('.'))
|
||||
Xnext
|
||||
@@ -4230,20 +4230,20 @@ func Xjumpto_first_error_test(cchar)
|
||||
" Test for cexpr/lexpr
|
||||
enew
|
||||
Xexpr l
|
||||
call assert_equal('Xtestfile1', bufname(''))
|
||||
call assert_equal('Xtestfile1', @%)
|
||||
call assert_equal(2, line('.'))
|
||||
|
||||
" Test for cfile/lfile
|
||||
enew
|
||||
call writefile(l, 'Xerr')
|
||||
Xfile Xerr
|
||||
call assert_equal('Xtestfile1', bufname(''))
|
||||
call assert_equal('Xtestfile1', @%)
|
||||
call assert_equal(2, line('.'))
|
||||
|
||||
" Test for cbuffer/lbuffer
|
||||
edit Xerr
|
||||
Xbuffer
|
||||
call assert_equal('Xtestfile1', bufname(''))
|
||||
call assert_equal('Xtestfile1', @%)
|
||||
call assert_equal(2, line('.'))
|
||||
|
||||
call delete('Xerr')
|
||||
@@ -4268,7 +4268,7 @@ func Xautocmd_changelist(cchar)
|
||||
autocmd QuickFixCmdPost * Xolder
|
||||
call writefile(['Xtestfile2:4:Line4'], 'Xerr')
|
||||
Xfile Xerr
|
||||
call assert_equal('Xtestfile2', bufname(''))
|
||||
call assert_equal('Xtestfile2', @%)
|
||||
call assert_equal(4, line('.'))
|
||||
autocmd! QuickFixCmdPost
|
||||
|
||||
@@ -4279,7 +4279,7 @@ func Xautocmd_changelist(cchar)
|
||||
call writefile(['Xtestfile2:4:Line4'], 'Xerr')
|
||||
edit Xerr
|
||||
Xbuffer
|
||||
call assert_equal('Xtestfile2', bufname(''))
|
||||
call assert_equal('Xtestfile2', @%)
|
||||
call assert_equal(4, line('.'))
|
||||
autocmd! QuickFixCmdPost
|
||||
|
||||
@@ -4288,7 +4288,7 @@ func Xautocmd_changelist(cchar)
|
||||
Xexpr 'Xtestfile1:2:Line2'
|
||||
autocmd QuickFixCmdPost * Xolder
|
||||
Xexpr 'Xtestfile2:4:Line4'
|
||||
call assert_equal('Xtestfile2', bufname(''))
|
||||
call assert_equal('Xtestfile2', @%)
|
||||
call assert_equal(4, line('.'))
|
||||
autocmd! QuickFixCmdPost
|
||||
|
||||
@@ -4299,7 +4299,7 @@ func Xautocmd_changelist(cchar)
|
||||
Xexpr 'Xtestfile1:2:Line2'
|
||||
autocmd QuickFixCmdPost * Xolder
|
||||
silent Xgrep Line5 Xtestfile2
|
||||
call assert_equal('Xtestfile2', bufname(''))
|
||||
call assert_equal('Xtestfile2', @%)
|
||||
call assert_equal(5, line('.'))
|
||||
autocmd! QuickFixCmdPost
|
||||
endif
|
||||
@@ -4309,7 +4309,7 @@ func Xautocmd_changelist(cchar)
|
||||
Xexpr 'Xtestfile1:2:Line2'
|
||||
autocmd QuickFixCmdPost * Xolder
|
||||
silent Xvimgrep Line5 Xtestfile2
|
||||
call assert_equal('Xtestfile2', bufname(''))
|
||||
call assert_equal('Xtestfile2', @%)
|
||||
call assert_equal(5, line('.'))
|
||||
autocmd! QuickFixCmdPost
|
||||
|
||||
@@ -4624,7 +4624,7 @@ func Test_winonly_autocmd()
|
||||
" positioned correctly.
|
||||
ll 3
|
||||
call assert_equal(loclistid, getloclist(0, {'id' : 0}).id)
|
||||
call assert_equal('Xtest1', bufname(''))
|
||||
call assert_equal('Xtest1', @%)
|
||||
call assert_equal(15, line('.'))
|
||||
" Cleanup
|
||||
autocmd! WinEnter
|
||||
@@ -4685,51 +4685,51 @@ func Xtest_below(cchar)
|
||||
Xexpr ["X1:5:3:L5", "X2:5:2:L5", "X2:10:3:L10", "X2:15:4:L15", "X3:3:5:L3"]
|
||||
edit +7 X2
|
||||
Xabove
|
||||
call assert_equal(['X2', 5], [bufname(''), line('.')])
|
||||
call assert_equal(['X2', 5], [@%, line('.')])
|
||||
call assert_fails('Xabove', 'E553:')
|
||||
normal 7G
|
||||
Xbefore
|
||||
call assert_equal(['X2', 5, 2], [bufname(''), line('.'), col('.')])
|
||||
call assert_equal(['X2', 5, 2], [@%, line('.'), col('.')])
|
||||
call assert_fails('Xbefore', 'E553:')
|
||||
|
||||
normal 2j
|
||||
Xbelow
|
||||
call assert_equal(['X2', 10], [bufname(''), line('.')])
|
||||
call assert_equal(['X2', 10], [@%, line('.')])
|
||||
normal 7G
|
||||
Xafter
|
||||
call assert_equal(['X2', 10, 3], [bufname(''), line('.'), col('.')])
|
||||
call assert_equal(['X2', 10, 3], [@%, line('.'), col('.')])
|
||||
|
||||
" Last error in this file
|
||||
Xbelow 99
|
||||
call assert_equal(['X2', 15], [bufname(''), line('.')])
|
||||
call assert_equal(['X2', 15], [@%, line('.')])
|
||||
call assert_fails('Xbelow', 'E553:')
|
||||
normal gg
|
||||
Xafter 99
|
||||
call assert_equal(['X2', 15, 4], [bufname(''), line('.'), col('.')])
|
||||
call assert_equal(['X2', 15, 4], [@%, line('.'), col('.')])
|
||||
call assert_fails('Xafter', 'E553:')
|
||||
|
||||
" First error in this file
|
||||
Xabove 99
|
||||
call assert_equal(['X2', 5], [bufname(''), line('.')])
|
||||
call assert_equal(['X2', 5], [@%, line('.')])
|
||||
call assert_fails('Xabove', 'E553:')
|
||||
normal G
|
||||
Xbefore 99
|
||||
call assert_equal(['X2', 5, 2], [bufname(''), line('.'), col('.')])
|
||||
call assert_equal(['X2', 5, 2], [@%, line('.'), col('.')])
|
||||
call assert_fails('Xbefore', 'E553:')
|
||||
|
||||
normal gg
|
||||
Xbelow 2
|
||||
call assert_equal(['X2', 10], [bufname(''), line('.')])
|
||||
call assert_equal(['X2', 10], [@%, line('.')])
|
||||
normal gg
|
||||
Xafter 2
|
||||
call assert_equal(['X2', 10, 3], [bufname(''), line('.'), col('.')])
|
||||
call assert_equal(['X2', 10, 3], [@%, line('.'), col('.')])
|
||||
|
||||
normal G
|
||||
Xabove 2
|
||||
call assert_equal(['X2', 10], [bufname(''), line('.')])
|
||||
call assert_equal(['X2', 10], [@%, line('.')])
|
||||
normal G
|
||||
Xbefore 2
|
||||
call assert_equal(['X2', 10, 3], [bufname(''), line('.'), col('.')])
|
||||
call assert_equal(['X2', 10, 3], [@%, line('.'), col('.')])
|
||||
|
||||
edit X4
|
||||
call assert_fails('Xabove', 'E42:')
|
||||
@@ -4753,45 +4753,45 @@ func Xtest_below(cchar)
|
||||
\ "X2:15:1:L15_1", "X2:15:2:L15_2", "X2:15:3:L15_3", "X3:3:L3"]
|
||||
edit +1 X2
|
||||
Xbelow 2
|
||||
call assert_equal(['X2', 10, 1], [bufname(''), line('.'), col('.')])
|
||||
call assert_equal(['X2', 10, 1], [@%, line('.'), col('.')])
|
||||
normal 1G
|
||||
Xafter 2
|
||||
call assert_equal(['X2', 5, 2], [bufname(''), line('.'), col('.')])
|
||||
call assert_equal(['X2', 5, 2], [@%, line('.'), col('.')])
|
||||
|
||||
normal gg
|
||||
Xbelow 99
|
||||
call assert_equal(['X2', 15, 1], [bufname(''), line('.'), col('.')])
|
||||
call assert_equal(['X2', 15, 1], [@%, line('.'), col('.')])
|
||||
normal gg
|
||||
Xafter 99
|
||||
call assert_equal(['X2', 15, 3], [bufname(''), line('.'), col('.')])
|
||||
call assert_equal(['X2', 15, 3], [@%, line('.'), col('.')])
|
||||
|
||||
normal G
|
||||
Xabove 2
|
||||
call assert_equal(['X2', 10, 1], [bufname(''), line('.'), col('.')])
|
||||
call assert_equal(['X2', 10, 1], [@%, line('.'), col('.')])
|
||||
normal G
|
||||
Xbefore 2
|
||||
call assert_equal(['X2', 15, 2], [bufname(''), line('.'), col('.')])
|
||||
call assert_equal(['X2', 15, 2], [@%, line('.'), col('.')])
|
||||
|
||||
normal G
|
||||
Xabove 99
|
||||
call assert_equal(['X2', 5, 1], [bufname(''), line('.'), col('.')])
|
||||
call assert_equal(['X2', 5, 1], [@%, line('.'), col('.')])
|
||||
normal G
|
||||
Xbefore 99
|
||||
call assert_equal(['X2', 5, 1], [bufname(''), line('.'), col('.')])
|
||||
call assert_equal(['X2', 5, 1], [@%, line('.'), col('.')])
|
||||
|
||||
normal 10G
|
||||
Xabove
|
||||
call assert_equal(['X2', 5, 1], [bufname(''), line('.'), col('.')])
|
||||
call assert_equal(['X2', 5, 1], [@%, line('.'), col('.')])
|
||||
normal 10G$
|
||||
2Xbefore
|
||||
call assert_equal(['X2', 10, 2], [bufname(''), line('.'), col('.')])
|
||||
call assert_equal(['X2', 10, 2], [@%, line('.'), col('.')])
|
||||
|
||||
normal 10G
|
||||
Xbelow
|
||||
call assert_equal(['X2', 15, 1], [bufname(''), line('.'), col('.')])
|
||||
call assert_equal(['X2', 15, 1], [@%, line('.'), col('.')])
|
||||
normal 9G
|
||||
5Xafter
|
||||
call assert_equal(['X2', 15, 2], [bufname(''), line('.'), col('.')])
|
||||
call assert_equal(['X2', 15, 2], [@%, line('.'), col('.')])
|
||||
|
||||
" Invalid range
|
||||
if a:cchar == 'c'
|
||||
|
||||
@@ -1732,6 +1732,34 @@ func Test_invalid_regexp()
|
||||
call assert_fails("call search('\\%#=3ab')", 'E864:')
|
||||
endfunc
|
||||
|
||||
" Test for searching with 'smartcase' and 'ignorecase'
|
||||
func Test_search_smartcase()
|
||||
new
|
||||
call setline(1, ['', 'Hello'])
|
||||
set noignorecase nosmartcase
|
||||
call assert_fails('exe "normal /\\a\\_.\\(.*\\)O\<CR>"', 'E486:')
|
||||
|
||||
set ignorecase nosmartcase
|
||||
exe "normal /\\a\\_.\\(.*\\)O\<CR>"
|
||||
call assert_equal([2, 1], [line('.'), col('.')])
|
||||
|
||||
call cursor(1, 1)
|
||||
set ignorecase smartcase
|
||||
call assert_fails('exe "normal /\\a\\_.\\(.*\\)O\<CR>"', 'E486:')
|
||||
|
||||
exe "normal /\\a\\_.\\(.*\\)o\<CR>"
|
||||
call assert_equal([2, 1], [line('.'), col('.')])
|
||||
|
||||
" Test for using special atoms with 'smartcase'
|
||||
call setline(1, ['', ' Hello\ '])
|
||||
call cursor(1, 1)
|
||||
call feedkeys('/\_.\%(\uello\)\' .. "\<CR>", 'xt')
|
||||
call assert_equal([2, 4], [line('.'), col('.')])
|
||||
|
||||
set ignorecase& smartcase&
|
||||
close!
|
||||
endfun
|
||||
|
||||
" Test 'smartcase' with utf-8.
|
||||
func Test_search_smartcase_utf8()
|
||||
new
|
||||
@@ -1751,6 +1779,102 @@ func Test_search_smartcase_utf8()
|
||||
close!
|
||||
endfunc
|
||||
|
||||
" Test searching past the end of a file
|
||||
func Test_search_past_eof()
|
||||
new
|
||||
call setline(1, ['Line'])
|
||||
exe "normal /\\n\\zs\<CR>"
|
||||
call assert_equal([1, 4], [line('.'), col('.')])
|
||||
close!
|
||||
endfunc
|
||||
|
||||
" Test for various search offsets
|
||||
func Test_search_offset()
|
||||
" With /e, for a match in the first column of a line, the cursor should be
|
||||
" placed at the end of the previous line.
|
||||
new
|
||||
call setline(1, ['one two', 'three four'])
|
||||
call search('two\_.', 'e')
|
||||
call assert_equal([1, 7], [line('.'), col('.')])
|
||||
|
||||
" with cursor at the beginning of the file, use /s+1
|
||||
call cursor(1, 1)
|
||||
exe "normal /two/s+1\<CR>"
|
||||
call assert_equal([1, 6], [line('.'), col('.')])
|
||||
|
||||
" with cursor at the end of the file, use /e-1
|
||||
call cursor(2, 10)
|
||||
exe "normal ?three?e-1\<CR>"
|
||||
call assert_equal([2, 4], [line('.'), col('.')])
|
||||
|
||||
" line offset - after the last line
|
||||
call cursor(1, 1)
|
||||
exe "normal /three/+1\<CR>"
|
||||
call assert_equal([2, 1], [line('.'), col('.')])
|
||||
|
||||
" line offset - before the first line
|
||||
call cursor(2, 1)
|
||||
exe "normal ?one?-1\<CR>"
|
||||
call assert_equal([1, 1], [line('.'), col('.')])
|
||||
|
||||
" character offset - before the first character in the file
|
||||
call cursor(2, 1)
|
||||
exe "normal ?one?s-1\<CR>"
|
||||
call assert_equal([1, 1], [line('.'), col('.')])
|
||||
call cursor(2, 1)
|
||||
exe "normal ?one?e-3\<CR>"
|
||||
call assert_equal([1, 1], [line('.'), col('.')])
|
||||
|
||||
" character offset - after the last character in the file
|
||||
call cursor(1, 1)
|
||||
exe "normal /four/s+4\<CR>"
|
||||
call assert_equal([2, 10], [line('.'), col('.')])
|
||||
call cursor(1, 1)
|
||||
exe "normal /four/e+1\<CR>"
|
||||
call assert_equal([2, 10], [line('.'), col('.')])
|
||||
|
||||
close!
|
||||
endfunc
|
||||
|
||||
" Test for searching for matching parenthesis using %
|
||||
func Test_search_match_paren()
|
||||
new
|
||||
call setline(1, "abc(def')'ghi'('jk'\\t'lm)no")
|
||||
" searching for a matching parenthesis should skip single quoted characters
|
||||
call cursor(1, 4)
|
||||
normal %
|
||||
call assert_equal([1, 25], [line('.'), col('.')])
|
||||
normal %
|
||||
call assert_equal([1, 4], [line('.'), col('.')])
|
||||
call cursor(1, 5)
|
||||
normal ])
|
||||
call assert_equal([1, 25], [line('.'), col('.')])
|
||||
call cursor(1, 24)
|
||||
normal [(
|
||||
call assert_equal([1, 4], [line('.'), col('.')])
|
||||
|
||||
" matching parenthesis in 'virtualedit' mode with cursor after the eol
|
||||
call setline(1, 'abc(defgh)')
|
||||
set virtualedit=all
|
||||
normal 20|%
|
||||
call assert_equal(4, col('.'))
|
||||
set virtualedit&
|
||||
close!
|
||||
endfunc
|
||||
|
||||
" Test for searching a pattern and stopping before a specified line
|
||||
func Test_search_stopline()
|
||||
new
|
||||
call setline(1, ['', '', '', 'vim'])
|
||||
call assert_equal(0, search('vim', 'n', 3))
|
||||
call assert_equal(4, search('vim', 'n', 4))
|
||||
call setline(1, ['vim', '', '', ''])
|
||||
call cursor(4, 1)
|
||||
call assert_equal(0, search('vim', 'bn', 2))
|
||||
call assert_equal(1, search('vim', 'bn', 1))
|
||||
close!
|
||||
endfunc
|
||||
|
||||
func Test_incsearch_highlighting_newline()
|
||||
CheckRunVimInTerminal
|
||||
CheckOption incsearch
|
||||
|
||||
@@ -1060,7 +1060,7 @@ func Test_tw_2_fo_tm_replace()
|
||||
endfunc
|
||||
|
||||
" Test for 'matchpairs' with multibyte chars
|
||||
func Test_mps()
|
||||
func Test_mps_multibyte()
|
||||
new
|
||||
let t =<< trim END
|
||||
{
|
||||
@@ -1084,6 +1084,30 @@ func Test_mps()
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
" Test for 'matchpairs' in latin1 encoding
|
||||
func Test_mps_latin1()
|
||||
new
|
||||
let save_enc = &encoding
|
||||
" set encoding=latin1
|
||||
call setline(1, 'abc(def)ghi')
|
||||
normal %
|
||||
call assert_equal(8, col('.'))
|
||||
normal %
|
||||
call assert_equal(4, col('.'))
|
||||
call cursor(1, 6)
|
||||
normal [(
|
||||
call assert_equal(4, col('.'))
|
||||
normal %
|
||||
call assert_equal(8, col('.'))
|
||||
call cursor(1, 6)
|
||||
normal ])
|
||||
call assert_equal(8, col('.'))
|
||||
normal %
|
||||
call assert_equal(4, col('.'))
|
||||
let &encoding = save_enc
|
||||
close!
|
||||
endfunc
|
||||
|
||||
func Test_empty_matchpairs()
|
||||
split
|
||||
set matchpairs= showmatch
|
||||
|
||||
@@ -233,6 +233,10 @@ func Test_empty_html_tag()
|
||||
normal 0f<vitsaaa
|
||||
call assert_equal('aaa', getline(1))
|
||||
|
||||
" selecting a tag block in an non-empty blank line should fail
|
||||
call setline(1, ' ')
|
||||
call assert_beeps('normal $vaty')
|
||||
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
@@ -367,6 +371,168 @@ func Test_sentence_with_cursor_on_delimiter()
|
||||
%delete _
|
||||
endfunc
|
||||
|
||||
" Test for the paragraph (ap) text object
|
||||
func Test_paragraph()
|
||||
new
|
||||
call setline(1, ['First line.', 'Second line.', 'Third line.'])
|
||||
call cursor(2, 1)
|
||||
normal vapy
|
||||
call assert_equal("First line.\nSecond line.\nThird line.\n", @")
|
||||
|
||||
call cursor(2, 1)
|
||||
call assert_beeps('normal vapapy')
|
||||
|
||||
call setline(1, ['First line.', 'Second line.', ' ', ''])
|
||||
call cursor(1, 1)
|
||||
normal vapy
|
||||
call assert_equal("First line.\nSecond line.\n \n\n", @")
|
||||
|
||||
call setline(1, ['', '', '', 'First line.', 'Second line.'])
|
||||
call cursor(2, 1)
|
||||
normal yap
|
||||
call assert_equal("\n\n\nFirst line.\nSecond line.\n", @")
|
||||
call assert_beeps('normal 3yap')
|
||||
exe "normal \<C-C>"
|
||||
|
||||
%d
|
||||
call setline(1, [' ', ' ', ' '])
|
||||
call cursor(2, 1)
|
||||
normal Vipy
|
||||
call assert_equal(" \n \n \n", @")
|
||||
call cursor(2, 1)
|
||||
call assert_beeps("normal Vipip")
|
||||
exe "normal \<C-C>"
|
||||
|
||||
close!
|
||||
endfunc
|
||||
|
||||
" Tests for text object aw
|
||||
func Test_textobj_a_word()
|
||||
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, '$'))
|
||||
" daw the last word in a line
|
||||
call setline(1, ['foo bar', 'foo bar', ''])
|
||||
call cursor(1, 5)
|
||||
normal daw
|
||||
call assert_equal('foo', getline(1))
|
||||
" aw in visual mode
|
||||
call cursor(2, 5)
|
||||
normal! vawx
|
||||
call assert_equal('foo', getline(2))
|
||||
%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,'$'))
|
||||
|
||||
" visually selecting a tab before a word with 'selection' set to 'exclusive'
|
||||
set selection=exclusive
|
||||
normal gg3lvlawy
|
||||
call assert_equal("\teins", @")
|
||||
" visually selecting a tab before a word with 'selection' set to 'inclusive'
|
||||
set selection=inclusive
|
||||
normal gg3lvlawy
|
||||
call assert_equal("\teins\t", @")
|
||||
set selection&
|
||||
|
||||
" selecting a word with no non-space characters in a buffer fails
|
||||
%d
|
||||
call setline(1, ' ')
|
||||
call assert_beeps('normal 3lyaw')
|
||||
|
||||
" visually selecting words backwards with no more words to select
|
||||
call setline(1, 'one two')
|
||||
call assert_beeps('normal 2lvh2aw')
|
||||
exe "normal \<C-C>"
|
||||
call assert_beeps('normal $vh3aw')
|
||||
exe "normal \<C-C>"
|
||||
call setline(1, ['', 'one two'])
|
||||
call assert_beeps('normal 2G2lvh3aw')
|
||||
exe "normal \<C-C>"
|
||||
|
||||
" selecting words forward with no more words to select
|
||||
%d
|
||||
call setline(1, 'one a')
|
||||
call assert_beeps('normal 0y3aw')
|
||||
call setline(1, 'one two ')
|
||||
call assert_beeps('normal 0y3aw')
|
||||
call assert_beeps('normal 03ly2aw')
|
||||
|
||||
" clean up
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
" Test for is and as text objects
|
||||
func Test_textobj_sentence()
|
||||
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,'$'))
|
||||
|
||||
" clean up
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
" Test for quote (', " and `) textobjects
|
||||
func Test_textobj_quote()
|
||||
new
|
||||
|
||||
@@ -1189,6 +1189,29 @@ func Test_AAA_start_visual_mode_with_count()
|
||||
close!
|
||||
endfunc
|
||||
|
||||
" Test for visually selecting an inner block (iB)
|
||||
func Test_visual_inner_block()
|
||||
new
|
||||
call setline(1, ['one', '{', 'two', '{', 'three', '}', 'four', '}', 'five'])
|
||||
call cursor(5, 1)
|
||||
" visually select all the lines in the block and then execute iB
|
||||
call feedkeys("ViB\<C-C>", 'xt')
|
||||
call assert_equal([0, 5, 1, 0], getpos("'<"))
|
||||
call assert_equal([0, 5, 6, 0], getpos("'>"))
|
||||
" visually select two inner blocks
|
||||
call feedkeys("ViBiB\<C-C>", 'xt')
|
||||
call assert_equal([0, 3, 1, 0], getpos("'<"))
|
||||
call assert_equal([0, 7, 5, 0], getpos("'>"))
|
||||
" try to select non-existing inner block
|
||||
call cursor(5, 1)
|
||||
call assert_beeps('normal ViBiBiB')
|
||||
" try to select a unclosed inner block
|
||||
8,9d
|
||||
call cursor(5, 1)
|
||||
call assert_beeps('normal ViBiB')
|
||||
close!
|
||||
endfunc
|
||||
|
||||
func Test_visual_put_in_block()
|
||||
new
|
||||
call setline(1, ['xxxx', 'y∞yy', 'zzzz'])
|
||||
|
||||
Reference in New Issue
Block a user