mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.2.2916: operators are not fully tested
Problem: Operators are not fully tested. Solution: Add a few more tests. (Yegappan Lakshmanan, closes #8290)
This commit is contained in:
committed by
Bram Moolenaar
parent
ef8706fb84
commit
2ac7184d34
@@ -2383,9 +2383,10 @@ op_addsub(
|
||||
#ifdef FEAT_NETBEANS_INTG
|
||||
if (netbeans_active() && one_change)
|
||||
{
|
||||
char_u *ptr = ml_get_buf(curbuf, pos.lnum, FALSE);
|
||||
char_u *ptr;
|
||||
|
||||
netbeans_removed(curbuf, pos.lnum, pos.col, (long)length);
|
||||
ptr = ml_get_buf(curbuf, pos.lnum, FALSE);
|
||||
netbeans_inserted(curbuf, pos.lnum, pos.col,
|
||||
&ptr[pos.col], length);
|
||||
}
|
||||
|
@@ -367,6 +367,46 @@ func Nb_basic(port)
|
||||
call assert_match('2:insert=\d\+ 26 "\t"', l[-1])
|
||||
let g:last += 18
|
||||
|
||||
" Test for changing case of multiple lines using ~
|
||||
normal ggVG~
|
||||
call WaitFor('len(ReadXnetbeans()) >= (g:last + 6)')
|
||||
let l = ReadXnetbeans()
|
||||
call assert_match('2:remove=\d\+ 0 8', l[-6])
|
||||
call assert_match('2:insert=\d\+ 0 "FOO BAR2"', l[-5])
|
||||
call assert_match('2:remove=\d\+ 9 8', l[-4])
|
||||
call assert_match('2:insert=\d\+ 9 "BLUE SKy"', l[-3])
|
||||
call assert_match('2:remove=\d\+ 18 9', l[-2])
|
||||
call assert_match('2:insert=\d\+ 18 "\tFOO BAR3"', l[-1])
|
||||
let g:last += 6
|
||||
|
||||
" Test for changing case of a visual block using ~
|
||||
exe "normal ggw\<C-V>$~"
|
||||
call WaitFor('len(ReadXnetbeans()) >= (g:last + 2)')
|
||||
let l = ReadXnetbeans()
|
||||
call assert_match('2:remove=\d\+ 4 4', l[-2])
|
||||
call assert_match('2:insert=\d\+ 4 "bar2"', l[-1])
|
||||
let g:last += 2
|
||||
|
||||
" Increment a number using <C-A> in visual mode
|
||||
exe "normal! gg$v6\<C-A>"
|
||||
call WaitFor('len(ReadXnetbeans()) >= (g:last + 6)')
|
||||
let l = ReadXnetbeans()
|
||||
call assert_match('2:remove=\d\+ 0 9', l[-4])
|
||||
call assert_match('2:insert=\d\+ 0 "FOO bar8"', l[-3])
|
||||
call assert_match('2:remove=\d\+ 7 1', l[-2])
|
||||
call assert_match('2:insert=\d\+ 7 "8"', l[-1])
|
||||
let g:last += 6
|
||||
|
||||
" Decrement a number using <C-X> in visual mode
|
||||
exe "normal! gg$v3\<C-X>"
|
||||
call WaitFor('len(ReadXnetbeans()) >= (g:last + 6)')
|
||||
let l = ReadXnetbeans()
|
||||
call assert_match('2:remove=\d\+ 0 9', l[-4])
|
||||
call assert_match('2:insert=\d\+ 0 "FOO bar5"', l[-3])
|
||||
call assert_match('2:remove=\d\+ 7 1', l[-2])
|
||||
call assert_match('2:insert=\d\+ 7 "5"', l[-1])
|
||||
let g:last += 6
|
||||
|
||||
" stopDocumentListen test
|
||||
call appendbufline(cmdbufnr, '$', 'stopDocumentListen_Test')
|
||||
call WaitFor('len(ReadXnetbeans()) >= (g:last + 3)')
|
||||
|
@@ -3377,4 +3377,34 @@ func Test_normal_shift_rightleft()
|
||||
bw!
|
||||
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()
|
||||
new
|
||||
setlocal shiftwidth=4 tabstop=8 autoindent
|
||||
call setline(1, ['one', 'two', 'three', 'four', 'five'])
|
||||
let @a = ''
|
||||
normal! j"ay4y
|
||||
call assert_equal("two\nthree\nfour\nfive\n", @a)
|
||||
normal! 3G>2>
|
||||
call assert_equal(['one', 'two', ' three', ' four', 'five'],
|
||||
\ getline(1, '$'))
|
||||
exe "normal! 3G0c2cred\nblue"
|
||||
call assert_equal(['one', 'two', ' red', ' blue', 'five'],
|
||||
\ getline(1, '$'))
|
||||
exe "normal! gg<8<"
|
||||
call assert_equal(['one', 'two', 'red', 'blue', 'five'],
|
||||
\ getline(1, '$'))
|
||||
exe "normal! ggd3d"
|
||||
call assert_equal(['blue', 'five'], getline(1, '$'))
|
||||
call setline(1, range(1, 4))
|
||||
call feedkeys("gg!3!\<C-B>\"\<CR>", 'xt')
|
||||
call assert_equal('".,.+2!', @:)
|
||||
call feedkeys("gg!1!\<C-B>\"\<CR>", 'xt')
|
||||
call assert_equal('".!', @:)
|
||||
call feedkeys("gg!9!\<C-B>\"\<CR>", 'xt')
|
||||
call assert_equal('".,$!', @:)
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
@@ -818,7 +818,99 @@ func Test_visual_block_mode()
|
||||
exe "normal ld\<C-V>j"
|
||||
call assert_equal(['13', '46', '789'], getline(1, '$'))
|
||||
|
||||
" Test from ':help v_b_I_example'
|
||||
%d _
|
||||
setlocal tabstop=8 shiftwidth=4
|
||||
let lines =<< trim END
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
abc defghijklmnopqrstuvwxyz
|
||||
abcdef ghi jklmnopqrstuvwxyz
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
END
|
||||
call setline(1, lines)
|
||||
exe "normal ggfo\<C-V>3jISTRING"
|
||||
let expected =<< trim END
|
||||
abcdefghijklmnSTRINGopqrstuvwxyz
|
||||
abc STRING defghijklmnopqrstuvwxyz
|
||||
abcdef ghi STRING jklmnopqrstuvwxyz
|
||||
abcdefghijklmnSTRINGopqrstuvwxyz
|
||||
END
|
||||
call assert_equal(expected, getline(1, '$'))
|
||||
|
||||
" Test from ':help v_b_A_example'
|
||||
%d _
|
||||
let lines =<< trim END
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
abc defghijklmnopqrstuvwxyz
|
||||
abcdef ghi jklmnopqrstuvwxyz
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
END
|
||||
call setline(1, lines)
|
||||
exe "normal ggfo\<C-V>3j$ASTRING"
|
||||
let expected =<< trim END
|
||||
abcdefghijklmnopqrstuvwxyzSTRING
|
||||
abc defghijklmnopqrstuvwxyzSTRING
|
||||
abcdef ghi jklmnopqrstuvwxyzSTRING
|
||||
abcdefghijklmnopqrstuvwxyzSTRING
|
||||
END
|
||||
call assert_equal(expected, getline(1, '$'))
|
||||
|
||||
" Test from ':help v_b_<_example'
|
||||
%d _
|
||||
let lines =<< trim END
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
abc defghijklmnopqrstuvwxyz
|
||||
abcdef ghi jklmnopqrstuvwxyz
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
END
|
||||
call setline(1, lines)
|
||||
exe "normal ggfo\<C-V>3j3l<.."
|
||||
let expected =<< trim END
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
abc defghijklmnopqrstuvwxyz
|
||||
abcdef ghi jklmnopqrstuvwxyz
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
END
|
||||
call assert_equal(expected, getline(1, '$'))
|
||||
|
||||
" Test from ':help v_b_>_example'
|
||||
%d _
|
||||
let lines =<< trim END
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
abc defghijklmnopqrstuvwxyz
|
||||
abcdef ghi jklmnopqrstuvwxyz
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
END
|
||||
call setline(1, lines)
|
||||
exe "normal ggfo\<C-V>3j>.."
|
||||
let expected =<< trim END
|
||||
abcdefghijklmn opqrstuvwxyz
|
||||
abc defghijklmnopqrstuvwxyz
|
||||
abcdef ghi jklmnopqrstuvwxyz
|
||||
abcdefghijklmn opqrstuvwxyz
|
||||
END
|
||||
call assert_equal(expected, getline(1, '$'))
|
||||
|
||||
" Test from ':help v_b_r_example'
|
||||
%d _
|
||||
let lines =<< trim END
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
abc defghijklmnopqrstuvwxyz
|
||||
abcdef ghi jklmnopqrstuvwxyz
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
END
|
||||
call setline(1, lines)
|
||||
exe "normal ggfo\<C-V>5l3jrX"
|
||||
let expected =<< trim END
|
||||
abcdefghijklmnXXXXXXuvwxyz
|
||||
abc XXXXXXhijklmnopqrstuvwxyz
|
||||
abcdef ghi XXXXXX jklmnopqrstuvwxyz
|
||||
abcdefghijklmnXXXXXXuvwxyz
|
||||
END
|
||||
call assert_equal(expected, getline(1, '$'))
|
||||
|
||||
bwipe!
|
||||
set tabstop& shiftwidth&
|
||||
endfunc
|
||||
|
||||
" Test block-insert using cursor keys for movement
|
||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
2916,
|
||||
/**/
|
||||
2915,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user