diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-01-17 22:16:00 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-01-17 22:16:00 +0100 |
commit | 8822744b4d9d40aa1fd59870a8bdd7c64c59a42b (patch) | |
tree | f3258d1a844a92aef79a2a52a19156211ff485f4 /src | |
parent | 5e4e1b12998b1ed99138cad1c5da4d430f798547 (diff) | |
download | vim-8822744b4d9d40aa1fd59870a8bdd7c64c59a42b.zip |
patch 8.0.0206: test coverage for :retab insufficient
Problem: Test coverage for :retab insufficient.
Solution: Add test for :retab. (Dominique Pelle, closes #1391)
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile | 1 | ||||
-rw-r--r-- | src/testdir/Make_all.mak | 1 | ||||
-rw-r--r-- | src/testdir/test_retab.vim | 77 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 81 insertions, 0 deletions
diff --git a/src/Makefile b/src/Makefile index 1070b23f7..0dcf10960 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2154,6 +2154,7 @@ test_arglist \ test_regexp_latin \ test_regexp_utf8 \ test_reltime \ + test_retab \ test_ruby \ test_search \ test_searchpos \ diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak index 5b9c5724c..e0da1b408 100644 --- a/src/testdir/Make_all.mak +++ b/src/testdir/Make_all.mak @@ -177,6 +177,7 @@ NEW_TESTS = test_arglist.res \ test_perl.res \ test_profile.res \ test_quickfix.res \ + test_retab.res \ test_ruby.res \ test_search.res \ test_signs.res \ diff --git a/src/testdir/test_retab.vim b/src/testdir/test_retab.vim new file mode 100644 index 000000000..f11a32bad --- /dev/null +++ b/src/testdir/test_retab.vim @@ -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 diff --git a/src/version.c b/src/version.c index 766f9890c..f3c4a4bf5 100644 --- a/src/version.c +++ b/src/version.c @@ -765,6 +765,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 206, +/**/ 205, /**/ 204, |