vim-patch:8.2.2901: some operators not fully tested

Problem:    Some operators not fully tested.
Solution:   Add a few test cases. (Yegappan Lakshmanan, closes vim/vim#8282)

3e72dcad8b
This commit is contained in:
zeertzjq
2022-11-04 20:41:53 +08:00
parent 26a9f786c4
commit 2aafaa5992
4 changed files with 76 additions and 0 deletions

View File

@@ -167,6 +167,7 @@ func Test_cpo_E()
call assert_beeps('normal "ayl') call assert_beeps('normal "ayl')
" change an empty line " change an empty line
call assert_beeps('normal lcTa') call assert_beeps('normal lcTa')
call assert_beeps('normal 0c0')
" delete an empty line " delete an empty line
call assert_beeps('normal D') call assert_beeps('normal D')
call assert_beeps('normal dl') call assert_beeps('normal dl')

View File

@@ -877,4 +877,21 @@ func Test_normal_increment_with_virtualedit()
set virtualedit& set virtualedit&
endfunc endfunc
" Test for incrementing a signed hexadecimal and octal number
func Test_normal_increment_signed_hexoct_nr()
new
" negative sign before a hex number should be ignored
call setline(1, ["-0x9"])
exe "norm \<C-A>"
call assert_equal(["-0xa"], getline(1, '$'))
exe "norm \<C-X>"
call assert_equal(["-0x9"], getline(1, '$'))
call setline(1, ["-007"])
exe "norm \<C-A>"
call assert_equal(["-010"], getline(1, '$'))
exe "norm \<C-X>"
call assert_equal(["-007"], getline(1, '$'))
bw!
endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@@ -2125,6 +2125,16 @@ func Test_normal30_changecase()
call assert_equal(['aaaaaa', 'AAAAaa'], getline(1, 2)) call assert_equal(['aaaaaa', 'AAAAaa'], getline(1, 2))
set whichwrap& set whichwrap&
" try changing the case with a double byte encoding (DBCS)
%bw!
let enc = &enc
" set encoding=cp932
call setline(1, "\u8470")
normal ~
normal gU$gu$gUgUg~g~gugu
call assert_equal("\u8470", getline(1))
let &encoding = enc
" clean up " clean up
bw! bw!
endfunc endfunc
@@ -3499,6 +3509,27 @@ func Test_normal_percent_jump()
close! close!
endfunc endfunc
" Test for << and >> commands to shift text by 'shiftwidth'
func Test_normal_shift_rightleft()
new
call setline(1, ['one', '', "\t", ' two', "\tthree", ' four'])
set shiftwidth=2 tabstop=8
normal gg6>>
call assert_equal([' one', '', "\t ", ' two', "\t three", "\tfour"],
\ getline(1, '$'))
normal ggVG2>>
call assert_equal([' one', '', "\t ", "\ttwo",
\ "\t three", "\t four"], getline(1, '$'))
normal gg6<<
call assert_equal([' one', '', "\t ", ' two', "\t three",
\ "\t four"], getline(1, '$'))
normal ggVG2<<
call assert_equal(['one', '', "\t", ' two', "\tthree", ' four'],
\ getline(1, '$'))
set shiftwidth& tabstop&
bw!
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()

View File

@@ -80,6 +80,10 @@ func Test_edit_change()
call setline(1, "\t⒌") call setline(1, "\t⒌")
normal Cx normal Cx
call assert_equal('x', getline(1)) call assert_equal('x', getline(1))
" Do a visual block change
call setline(1, ['a', 'b', 'c'])
exe "normal gg3l\<C-V>2jcx"
call assert_equal(['a x', 'b x', 'c x'], getline(1, '$'))
bwipe! bwipe!
set virtualedit= set virtualedit=
endfunc endfunc
@@ -289,6 +293,16 @@ func Test_replace_after_eol()
call append(0, '"r"') call append(0, '"r"')
normal gg$5lrxa normal gg$5lrxa
call assert_equal('"r" x', getline(1)) call assert_equal('"r" x', getline(1))
" visual block replace
%d _
call setline(1, ['a', '', 'b'])
exe "normal 2l\<C-V>2jrx"
call assert_equal(['a x', ' x', 'b x'], getline(1, '$'))
" visual characterwise selection replace after eol
%d _
call setline(1, 'a')
normal 4lv2lrx
call assert_equal('a xxx', getline(1))
bwipe! bwipe!
set virtualedit= set virtualedit=
endfunc endfunc
@@ -375,6 +389,19 @@ func Test_ve_backspace()
close! close!
endfunc endfunc
" Test for delete (x) on EOL character and after EOL
func Test_delete_past_eol()
new
call setline(1, "ab")
set virtualedit=all
exe "normal 2lx"
call assert_equal('ab', getline(1))
exe "normal 10lx"
call assert_equal('ab', getline(1))
set virtualedit&
bw!
endfunc
" After calling s:TryVirtualeditReplace(), line 1 will contain one of these " After calling s:TryVirtualeditReplace(), line 1 will contain one of these
" two strings, depending on whether virtual editing is on or off. " two strings, depending on whether virtual editing is on or off.
let s:result_ve_on = 'a x' let s:result_ve_on = 'a x'