mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
patch 8.0.0206: test coverage for :retab insufficient
Problem: Test coverage for :retab insufficient. Solution: Add test for :retab. (Dominique Pelle, closes #1391)
This commit is contained in:
@@ -2154,6 +2154,7 @@ test_arglist \
|
|||||||
test_regexp_latin \
|
test_regexp_latin \
|
||||||
test_regexp_utf8 \
|
test_regexp_utf8 \
|
||||||
test_reltime \
|
test_reltime \
|
||||||
|
test_retab \
|
||||||
test_ruby \
|
test_ruby \
|
||||||
test_search \
|
test_search \
|
||||||
test_searchpos \
|
test_searchpos \
|
||||||
|
@@ -177,6 +177,7 @@ NEW_TESTS = test_arglist.res \
|
|||||||
test_perl.res \
|
test_perl.res \
|
||||||
test_profile.res \
|
test_profile.res \
|
||||||
test_quickfix.res \
|
test_quickfix.res \
|
||||||
|
test_retab.res \
|
||||||
test_ruby.res \
|
test_ruby.res \
|
||||||
test_search.res \
|
test_search.res \
|
||||||
test_signs.res \
|
test_signs.res \
|
||||||
|
77
src/testdir/test_retab.vim
Normal file
77
src/testdir/test_retab.vim
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
" Test :retab
|
||||||
|
func SetUp()
|
||||||
|
new
|
||||||
|
call setline(1, "\ta \t b c ")
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func TearDown()
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Retab(bang, n)
|
||||||
|
let l:old_tabstop = &tabstop
|
||||||
|
let l:old_line = getline(1)
|
||||||
|
exe "retab" . a:bang . a:n
|
||||||
|
let l:line = getline(1)
|
||||||
|
call setline(1, l:old_line)
|
||||||
|
if a:n > 0
|
||||||
|
" :retab changes 'tabstop' to n with argument n > 0.
|
||||||
|
call assert_equal(a:n, &tabstop)
|
||||||
|
exe 'set tabstop=' . l:old_tabstop
|
||||||
|
else
|
||||||
|
" :retab does not change 'tabstop' with empty or n <= 0.
|
||||||
|
call assert_equal(l:old_tabstop, &tabstop)
|
||||||
|
endif
|
||||||
|
return l:line
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_retab()
|
||||||
|
set tabstop=8 noexpandtab
|
||||||
|
call assert_equal("\ta\t b c ", Retab('', ''))
|
||||||
|
call assert_equal("\ta\t b c ", Retab('', 0))
|
||||||
|
call assert_equal("\ta\t b c ", Retab('', 8))
|
||||||
|
call assert_equal("\ta\t b\t c\t ", Retab('!', ''))
|
||||||
|
call assert_equal("\ta\t b\t c\t ", Retab('!', 0))
|
||||||
|
call assert_equal("\ta\t b\t c\t ", Retab('!', 8))
|
||||||
|
|
||||||
|
call assert_equal("\t\ta\t\t\tb c ", Retab('', 4))
|
||||||
|
call assert_equal("\t\ta\t\t\tb\t\t c\t ", Retab('!', 4))
|
||||||
|
|
||||||
|
call assert_equal(" a\t\tb c ", Retab('', 10))
|
||||||
|
call assert_equal(" a\t\tb c ", Retab('!', 10))
|
||||||
|
|
||||||
|
set tabstop=8 expandtab
|
||||||
|
call assert_equal(" a b c ", Retab('', ''))
|
||||||
|
call assert_equal(" a b c ", Retab('', 0))
|
||||||
|
call assert_equal(" a b c ", Retab('', 8))
|
||||||
|
call assert_equal(" a b c ", Retab('!', ''))
|
||||||
|
call assert_equal(" a b c ", Retab('!', 0))
|
||||||
|
call assert_equal(" a b c ", Retab('!', 8))
|
||||||
|
|
||||||
|
call assert_equal(" a b c ", Retab(' ', 4))
|
||||||
|
call assert_equal(" a b c ", Retab('!', 4))
|
||||||
|
|
||||||
|
call assert_equal(" a b c ", Retab(' ', 10))
|
||||||
|
call assert_equal(" a b c ", Retab('!', 10))
|
||||||
|
|
||||||
|
set tabstop=4 noexpandtab
|
||||||
|
call assert_equal("\ta\t\tb c ", Retab('', ''))
|
||||||
|
call assert_equal("\ta\t\tb\t\t c\t ", Retab('!', ''))
|
||||||
|
call assert_equal("\t a\t\t\tb c ", Retab('', 3))
|
||||||
|
call assert_equal("\t a\t\t\tb\t\t\tc\t ", Retab('!', 3))
|
||||||
|
call assert_equal(" a\t b c ", Retab('', 5))
|
||||||
|
call assert_equal(" a\t b\t\t c\t ", Retab('!', 5))
|
||||||
|
|
||||||
|
set tabstop=4 expandtab
|
||||||
|
call assert_equal(" a b c ", Retab('', ''))
|
||||||
|
call assert_equal(" a b c ", Retab('!', ''))
|
||||||
|
call assert_equal(" a b c ", Retab('', 3))
|
||||||
|
call assert_equal(" a b c ", Retab('!', 3))
|
||||||
|
call assert_equal(" a b c ", Retab('', 5))
|
||||||
|
call assert_equal(" a b c ", Retab('!', 5))
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_retab_error()
|
||||||
|
call assert_fails('retab -1', 'E487:')
|
||||||
|
call assert_fails('retab! -1', 'E487:')
|
||||||
|
endfunc
|
@@ -764,6 +764,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
206,
|
||||||
/**/
|
/**/
|
||||||
205,
|
205,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user