mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.1786: various Normal mode commands not fully tested
Problem: Various Normal mode commands not fully tested.
Solution: Add more tests. (Yegappan Lakshmanan, closes vim/vim#7059)
8a9bc95eae
Cherry-pick Test_normal_gdollar_cmd() change from patch 8.2.0540.
This commit is contained in:
parent
d334249833
commit
37586eac42
@ -655,6 +655,19 @@ func Test_normal15_z_scroll_vert()
|
|||||||
call assert_equal(21, winsaveview()['topline'])
|
call assert_equal(21, winsaveview()['topline'])
|
||||||
call assert_equal([0, 21, 2, 0, 9], getcurpos())
|
call assert_equal([0, 21, 2, 0, 9], getcurpos())
|
||||||
|
|
||||||
|
" Test for z+ with [count] greater than buffer size
|
||||||
|
1
|
||||||
|
norm! 1000z+
|
||||||
|
call assert_equal(' 100', getline('.'))
|
||||||
|
call assert_equal(100, winsaveview()['topline'])
|
||||||
|
call assert_equal([0, 100, 2, 0, 9], getcurpos())
|
||||||
|
|
||||||
|
" Test for z+ from the last buffer line
|
||||||
|
norm! Gz.z+
|
||||||
|
call assert_equal(' 100', getline('.'))
|
||||||
|
call assert_equal(100, winsaveview()['topline'])
|
||||||
|
call assert_equal([0, 100, 2, 0, 9], getcurpos())
|
||||||
|
|
||||||
" Test for z^
|
" Test for z^
|
||||||
norm! 22z+0
|
norm! 22z+0
|
||||||
norm! z^
|
norm! z^
|
||||||
@ -662,6 +675,12 @@ func Test_normal15_z_scroll_vert()
|
|||||||
call assert_equal(12, winsaveview()['topline'])
|
call assert_equal(12, winsaveview()['topline'])
|
||||||
call assert_equal([0, 21, 2, 0, 9], getcurpos())
|
call assert_equal([0, 21, 2, 0, 9], getcurpos())
|
||||||
|
|
||||||
|
" Test for z^ from first buffer line
|
||||||
|
norm! ggz^
|
||||||
|
call assert_equal('1', getline('.'))
|
||||||
|
call assert_equal(1, winsaveview()['topline'])
|
||||||
|
call assert_equal([0, 1, 1, 0, 1], getcurpos())
|
||||||
|
|
||||||
" Test for [count]z^
|
" Test for [count]z^
|
||||||
1
|
1
|
||||||
norm! 30z^
|
norm! 30z^
|
||||||
@ -741,6 +760,19 @@ func Test_normal16_z_scroll_hor()
|
|||||||
norm! yl
|
norm! yl
|
||||||
call assert_equal('z', @0)
|
call assert_equal('z', @0)
|
||||||
|
|
||||||
|
" Test for zs and ze with folds
|
||||||
|
%fold
|
||||||
|
norm! $zs
|
||||||
|
call assert_equal(26, col('.'))
|
||||||
|
call assert_equal(0, winsaveview()['leftcol'])
|
||||||
|
norm! yl
|
||||||
|
call assert_equal('z', @0)
|
||||||
|
norm! ze
|
||||||
|
call assert_equal(26, col('.'))
|
||||||
|
call assert_equal(0, winsaveview()['leftcol'])
|
||||||
|
norm! yl
|
||||||
|
call assert_equal('z', @0)
|
||||||
|
|
||||||
" cleanup
|
" cleanup
|
||||||
set wrap listchars=eol:$
|
set wrap listchars=eol:$
|
||||||
bw!
|
bw!
|
||||||
@ -834,6 +866,19 @@ func Test_vert_scroll_cmds()
|
|||||||
normal! 4H
|
normal! 4H
|
||||||
call assert_equal(33, line('.'))
|
call assert_equal(33, line('.'))
|
||||||
|
|
||||||
|
" Test for using a large count value
|
||||||
|
%d
|
||||||
|
call setline(1, range(1, 4))
|
||||||
|
norm! 6H
|
||||||
|
call assert_equal(4, line('.'))
|
||||||
|
|
||||||
|
" Test for 'M' with folded lines
|
||||||
|
%d
|
||||||
|
call setline(1, range(1, 20))
|
||||||
|
1,5fold
|
||||||
|
norm! LM
|
||||||
|
call assert_equal(12, line('.'))
|
||||||
|
|
||||||
" Test for the CTRL-E and CTRL-Y commands with folds
|
" Test for the CTRL-E and CTRL-Y commands with folds
|
||||||
%d
|
%d
|
||||||
call setline(1, range(1, 10))
|
call setline(1, range(1, 10))
|
||||||
@ -1214,6 +1259,13 @@ func Test_normal18_z_fold()
|
|||||||
norm! j
|
norm! j
|
||||||
call assert_equal('55', getline('.'))
|
call assert_equal('55', getline('.'))
|
||||||
|
|
||||||
|
" Test for zm with a count
|
||||||
|
50
|
||||||
|
set foldlevel=2
|
||||||
|
norm! 3zm
|
||||||
|
call assert_equal(0, &foldlevel)
|
||||||
|
call assert_equal(49, foldclosed(line('.')))
|
||||||
|
|
||||||
" Test for zM
|
" Test for zM
|
||||||
48
|
48
|
||||||
set nofoldenable foldlevel=99
|
set nofoldenable foldlevel=99
|
||||||
@ -1421,6 +1473,15 @@ func Test_normal23_K()
|
|||||||
set iskeyword-=%
|
set iskeyword-=%
|
||||||
set iskeyword-=\|
|
set iskeyword-=\|
|
||||||
|
|
||||||
|
" Currently doesn't work in Nvim, see #19436
|
||||||
|
" Test for specifying a count to K
|
||||||
|
" 1
|
||||||
|
" com! -nargs=* Kprog let g:Kprog_Args = <q-args>
|
||||||
|
" set keywordprg=:Kprog
|
||||||
|
" norm! 3K
|
||||||
|
" call assert_equal('3 version8', g:Kprog_Args)
|
||||||
|
" delcom Kprog
|
||||||
|
|
||||||
" Only expect "man" to work on Unix
|
" Only expect "man" to work on Unix
|
||||||
if !has("unix") || has('nvim') " Nvim K uses :terminal. #15398
|
if !has("unix") || has('nvim') " Nvim K uses :terminal. #15398
|
||||||
let &keywordprg = k
|
let &keywordprg = k
|
||||||
@ -1868,6 +1929,30 @@ func Test_normal29_brace()
|
|||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for section movements
|
||||||
|
func Test_normal_section()
|
||||||
|
new
|
||||||
|
let lines =<< trim [END]
|
||||||
|
int foo()
|
||||||
|
{
|
||||||
|
if (1)
|
||||||
|
{
|
||||||
|
a = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[END]
|
||||||
|
call setline(1, lines)
|
||||||
|
|
||||||
|
" jumping to a folded line using [[ should open the fold
|
||||||
|
2,3fold
|
||||||
|
call cursor(5, 1)
|
||||||
|
call feedkeys("[[", 'xt')
|
||||||
|
call assert_equal(2, line('.'))
|
||||||
|
call assert_equal(-1, foldclosedend(line('.')))
|
||||||
|
|
||||||
|
close!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Test for ~ command
|
" Test for ~ command
|
||||||
func Test_normal30_changecase()
|
func Test_normal30_changecase()
|
||||||
new
|
new
|
||||||
@ -2912,25 +2997,26 @@ func Test_java_motion()
|
|||||||
call assert_beeps('normal! ]m')
|
call assert_beeps('normal! ]m')
|
||||||
call assert_beeps('normal! [M')
|
call assert_beeps('normal! [M')
|
||||||
call assert_beeps('normal! ]M')
|
call assert_beeps('normal! ]M')
|
||||||
a
|
let lines =<< trim [CODE]
|
||||||
Piece of Java
|
Piece of Java
|
||||||
{
|
{
|
||||||
tt m1 {
|
tt m1 {
|
||||||
t1;
|
t1;
|
||||||
} e1
|
} e1
|
||||||
|
|
||||||
tt m2 {
|
tt m2 {
|
||||||
t2;
|
t2;
|
||||||
} e2
|
} e2
|
||||||
|
|
||||||
tt m3 {
|
tt m3 {
|
||||||
if (x)
|
if (x)
|
||||||
{
|
{
|
||||||
t3;
|
t3;
|
||||||
}
|
}
|
||||||
} e3
|
} e3
|
||||||
}
|
}
|
||||||
.
|
[CODE]
|
||||||
|
call setline(1, lines)
|
||||||
|
|
||||||
normal gg
|
normal gg
|
||||||
|
|
||||||
@ -2983,14 +3069,21 @@ Piece of Java
|
|||||||
call assert_equal("{LF", getline('.'))
|
call assert_equal("{LF", getline('.'))
|
||||||
call assert_equal([2, 2, 2], [line('.'), col('.'), virtcol('.')])
|
call assert_equal([2, 2, 2], [line('.'), col('.'), virtcol('.')])
|
||||||
|
|
||||||
|
call cursor(2, 1)
|
||||||
|
call assert_beeps('norm! 5]m')
|
||||||
|
|
||||||
|
" jumping to a method in a fold should open the fold
|
||||||
|
6,10fold
|
||||||
|
call feedkeys("gg3]m", 'xt')
|
||||||
|
call assert_equal([7, 8, 15], [line('.'), col('.'), virtcol('.')])
|
||||||
|
call assert_equal(-1, foldclosedend(7))
|
||||||
|
|
||||||
close!
|
close!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Tests for g cmds
|
||||||
func Test_normal_gdollar_cmd()
|
func Test_normal_gdollar_cmd()
|
||||||
if !has("jumplist")
|
CheckFeature jumplist
|
||||||
return
|
|
||||||
endif
|
|
||||||
" Tests for g cmds
|
|
||||||
call Setup_NewWindow()
|
call Setup_NewWindow()
|
||||||
" Make long lines that will wrap
|
" Make long lines that will wrap
|
||||||
%s/$/\=repeat(' foobar', 10)/
|
%s/$/\=repeat(' foobar', 10)/
|
||||||
@ -3198,6 +3291,27 @@ func Test_normal_colon_op()
|
|||||||
close!
|
close!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for deleting or changing characters across lines with 'whichwrap'
|
||||||
|
" containing 's'. Should count <EOL> as one character.
|
||||||
|
func Test_normal_op_across_lines()
|
||||||
|
new
|
||||||
|
set whichwrap&
|
||||||
|
call setline(1, ['one two', 'three four'])
|
||||||
|
exe "norm! $3d\<Space>"
|
||||||
|
call assert_equal(['one twhree four'], getline(1, '$'))
|
||||||
|
|
||||||
|
call setline(1, ['one two', 'three four'])
|
||||||
|
exe "norm! $3c\<Space>x"
|
||||||
|
call assert_equal(['one twxhree four'], getline(1, '$'))
|
||||||
|
|
||||||
|
set whichwrap+=l
|
||||||
|
call setline(1, ['one two', 'three four'])
|
||||||
|
exe "norm! $3x"
|
||||||
|
call assert_equal(['one twhree four'], getline(1, '$'))
|
||||||
|
close!
|
||||||
|
set whichwrap&
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Test for 'w' and 'b' commands
|
" Test for 'w' and 'b' commands
|
||||||
func Test_normal_word_move()
|
func Test_normal_word_move()
|
||||||
new
|
new
|
||||||
@ -3271,6 +3385,19 @@ func Test_normal_vert_scroll_longline()
|
|||||||
close!
|
close!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for jumping in a file using %
|
||||||
|
func Test_normal_percent_jump()
|
||||||
|
new
|
||||||
|
call setline(1, range(1, 100))
|
||||||
|
|
||||||
|
" jumping to a folded line should open the fold
|
||||||
|
25,75fold
|
||||||
|
call feedkeys('50%', 'xt')
|
||||||
|
call assert_equal(50, line('.'))
|
||||||
|
call assert_equal(-1, foldclosedend(50))
|
||||||
|
close!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Some commands like yy, cc, dd, >>, << and !! accept a count after
|
" Some commands like yy, cc, dd, >>, << and !! accept a count after
|
||||||
" typing the first letter of the command.
|
" typing the first letter of the command.
|
||||||
func Test_normal_count_after_operator()
|
func Test_normal_count_after_operator()
|
||||||
|
@ -522,8 +522,8 @@ endfunc
|
|||||||
func Test_search_with_end_offset()
|
func Test_search_with_end_offset()
|
||||||
new
|
new
|
||||||
call setline(1, ['', 'dog(a', 'cat('])
|
call setline(1, ['', 'dog(a', 'cat('])
|
||||||
exe "normal /(/e+" .. "\<CR>"
|
exe "normal /(/e+\<CR>"
|
||||||
normal "ayn
|
normal n"ayn
|
||||||
call assert_equal("a\ncat(", @a)
|
call assert_equal("a\ncat(", @a)
|
||||||
close!
|
close!
|
||||||
endfunc
|
endfunc
|
||||||
|
@ -426,6 +426,12 @@ func Test_execute_register()
|
|||||||
@
|
@
|
||||||
call assert_equal(3, i)
|
call assert_equal(3, i)
|
||||||
|
|
||||||
|
" try to execute expression register and use a backspace to cancel it
|
||||||
|
new
|
||||||
|
call feedkeys("@=\<BS>ax\<CR>y", 'xt')
|
||||||
|
call assert_equal(['x', 'y'], getline(1, '$'))
|
||||||
|
close!
|
||||||
|
|
||||||
" cannot execute a register in operator pending mode
|
" cannot execute a register in operator pending mode
|
||||||
call assert_beeps('normal! c@r')
|
call assert_beeps('normal! c@r')
|
||||||
endfunc
|
endfunc
|
||||||
|
@ -25,6 +25,18 @@ func Test_spell_normal()
|
|||||||
let cnt=readfile('./Xspellfile.add')
|
let cnt=readfile('./Xspellfile.add')
|
||||||
call assert_equal('goood', cnt[0])
|
call assert_equal('goood', cnt[0])
|
||||||
|
|
||||||
|
" zg should fail in operator-pending mode
|
||||||
|
call assert_beeps('norm! czg')
|
||||||
|
|
||||||
|
" zg fails in visual mode when not able to get the visual text
|
||||||
|
call assert_beeps('norm! ggVjzg')
|
||||||
|
norm! V
|
||||||
|
|
||||||
|
" zg fails for a non-identifier word
|
||||||
|
call append(line('$'), '###')
|
||||||
|
call assert_fails('norm! Gzg', 'E349:')
|
||||||
|
$d
|
||||||
|
|
||||||
" Test for zw
|
" Test for zw
|
||||||
2
|
2
|
||||||
norm! $zw
|
norm! $zw
|
||||||
|
@ -1133,7 +1133,7 @@ endfunc
|
|||||||
" Test for [i, ]i, [I, ]I, [ CTRL-I, ] CTRL-I and CTRL-W i commands
|
" Test for [i, ]i, [I, ]I, [ CTRL-I, ] CTRL-I and CTRL-W i commands
|
||||||
func Test_inc_search()
|
func Test_inc_search()
|
||||||
new
|
new
|
||||||
call setline(1, ['1:foo', '2:foo', 'foo', '3:foo', '4:foo'])
|
call setline(1, ['1:foo', '2:foo', 'foo', '3:foo', '4:foo', '==='])
|
||||||
call cursor(3, 1)
|
call cursor(3, 1)
|
||||||
|
|
||||||
" Test for [i and ]i
|
" Test for [i and ]i
|
||||||
@ -1143,6 +1143,9 @@ func Test_inc_search()
|
|||||||
call assert_equal('3:foo', execute('normal ]i'))
|
call assert_equal('3:foo', execute('normal ]i'))
|
||||||
call assert_equal('4:foo', execute('normal 2]i'))
|
call assert_equal('4:foo', execute('normal 2]i'))
|
||||||
call assert_fails('normal 3]i', 'E389:')
|
call assert_fails('normal 3]i', 'E389:')
|
||||||
|
call assert_fails('normal G]i', 'E349:')
|
||||||
|
call assert_fails('normal [i', 'E349:')
|
||||||
|
call cursor(3, 1)
|
||||||
|
|
||||||
" Test for :isearch
|
" Test for :isearch
|
||||||
call assert_equal('1:foo', execute('isearch foo'))
|
call assert_equal('1:foo', execute('isearch foo'))
|
||||||
@ -1163,6 +1166,9 @@ func Test_inc_search()
|
|||||||
call assert_equal([
|
call assert_equal([
|
||||||
\ ' 1: 4 3:foo',
|
\ ' 1: 4 3:foo',
|
||||||
\ ' 2: 5 4:foo'], split(execute('normal ]I'), "\n"))
|
\ ' 2: 5 4:foo'], split(execute('normal ]I'), "\n"))
|
||||||
|
call assert_fails('normal G]I', 'E349:')
|
||||||
|
call assert_fails('normal [I', 'E349:')
|
||||||
|
call cursor(3, 1)
|
||||||
|
|
||||||
" Test for :ilist
|
" Test for :ilist
|
||||||
call assert_equal([
|
call assert_equal([
|
||||||
@ -1188,6 +1194,9 @@ func Test_inc_search()
|
|||||||
exe "normal k2]\t"
|
exe "normal k2]\t"
|
||||||
call assert_equal([5, 3], [line('.'), col('.')])
|
call assert_equal([5, 3], [line('.'), col('.')])
|
||||||
call assert_fails("normal 2k3]\t", 'E389:')
|
call assert_fails("normal 2k3]\t", 'E389:')
|
||||||
|
call assert_fails("normal G[\t", 'E349:')
|
||||||
|
call assert_fails("normal ]\t", 'E349:')
|
||||||
|
call cursor(3, 1)
|
||||||
|
|
||||||
" Test for :ijump
|
" Test for :ijump
|
||||||
call cursor(3, 1)
|
call cursor(3, 1)
|
||||||
@ -1212,6 +1221,8 @@ func Test_inc_search()
|
|||||||
close
|
close
|
||||||
call assert_fails('3wincmd i', 'E387:')
|
call assert_fails('3wincmd i', 'E387:')
|
||||||
call assert_fails('6wincmd i', 'E389:')
|
call assert_fails('6wincmd i', 'E389:')
|
||||||
|
call assert_fails("normal G\<C-W>i", 'E349:')
|
||||||
|
call cursor(3, 1)
|
||||||
|
|
||||||
" Test for :isplit
|
" Test for :isplit
|
||||||
isplit foo
|
isplit foo
|
||||||
|
@ -378,14 +378,17 @@ endfunc
|
|||||||
|
|
||||||
func Test_Visual_paragraph_textobject()
|
func Test_Visual_paragraph_textobject()
|
||||||
new
|
new
|
||||||
call setline(1, ['First line.',
|
let lines =<< trim [END]
|
||||||
\ '',
|
First line.
|
||||||
\ 'Second line.',
|
|
||||||
\ 'Third line.',
|
Second line.
|
||||||
\ 'Fourth line.',
|
Third line.
|
||||||
\ 'Fifth line.',
|
Fourth line.
|
||||||
\ '',
|
Fifth line.
|
||||||
\ 'Sixth line.'])
|
|
||||||
|
Sixth line.
|
||||||
|
[END]
|
||||||
|
call setline(1, lines)
|
||||||
|
|
||||||
" When start and end of visual area are identical, 'ap' or 'ip' select
|
" When start and end of visual area are identical, 'ap' or 'ip' select
|
||||||
" the whole paragraph.
|
" the whole paragraph.
|
||||||
@ -639,6 +642,20 @@ func Test_characterwise_visual_mode()
|
|||||||
normal Gkvj$d
|
normal Gkvj$d
|
||||||
call assert_equal(['', 'a', ''], getline(1, '$'))
|
call assert_equal(['', 'a', ''], getline(1, '$'))
|
||||||
|
|
||||||
|
" characterwise visual mode: use a count with the visual mode
|
||||||
|
%d _
|
||||||
|
call setline(1, 'one two three')
|
||||||
|
norm! vy5vy
|
||||||
|
call assert_equal('one t', @")
|
||||||
|
|
||||||
|
" characterwise visual mode: use a count with the visual mode from the last
|
||||||
|
" line in the buffer
|
||||||
|
%d _
|
||||||
|
call setline(1, ['one', 'two', 'three', 'four'])
|
||||||
|
norm! vj$y
|
||||||
|
norm! G1vy
|
||||||
|
call assert_equal('four', @")
|
||||||
|
|
||||||
" characterwise visual mode: replace a single character line and the eol
|
" characterwise visual mode: replace a single character line and the eol
|
||||||
%d _
|
%d _
|
||||||
call setline(1, "a")
|
call setline(1, "a")
|
||||||
|
Loading…
Reference in New Issue
Block a user