Skip to content

Commit 8822744

Browse files
committed
patch 8.0.0206: test coverage for :retab insufficient
Problem: Test coverage for :retab insufficient. Solution: Add test for :retab. (Dominique Pelle, closes #1391)
1 parent 5e4e1b1 commit 8822744

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed

src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,6 +2154,7 @@ test_arglist \
21542154
test_regexp_latin \
21552155
test_regexp_utf8 \
21562156
test_reltime \
2157+
test_retab \
21572158
test_ruby \
21582159
test_search \
21592160
test_searchpos \

src/testdir/Make_all.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ NEW_TESTS = test_arglist.res \
177177
test_perl.res \
178178
test_profile.res \
179179
test_quickfix.res \
180+
test_retab.res \
180181
test_ruby.res \
181182
test_search.res \
182183
test_signs.res \

src/testdir/test_retab.vim

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
" Test :retab
2+
func SetUp()
3+
new
4+
call setline(1, "\ta \t b c ")
5+
endfunc
6+
7+
func TearDown()
8+
bwipe!
9+
endfunc
10+
11+
func Retab(bang, n)
12+
let l:old_tabstop = &tabstop
13+
let l:old_line = getline(1)
14+
exe "retab" . a:bang . a:n
15+
let l:line = getline(1)
16+
call setline(1, l:old_line)
17+
if a:n > 0
18+
" :retab changes 'tabstop' to n with argument n > 0.
19+
call assert_equal(a:n, &tabstop)
20+
exe 'set tabstop=' . l:old_tabstop
21+
else
22+
" :retab does not change 'tabstop' with empty or n <= 0.
23+
call assert_equal(l:old_tabstop, &tabstop)
24+
endif
25+
return l:line
26+
endfunc
27+
28+
func Test_retab()
29+
set tabstop=8 noexpandtab
30+
call assert_equal("\ta\t b c ", Retab('', ''))
31+
call assert_equal("\ta\t b c ", Retab('', 0))
32+
call assert_equal("\ta\t b c ", Retab('', 8))
33+
call assert_equal("\ta\t b\t c\t ", Retab('!', ''))
34+
call assert_equal("\ta\t b\t c\t ", Retab('!', 0))
35+
call assert_equal("\ta\t b\t c\t ", Retab('!', 8))
36+
37+
call assert_equal("\t\ta\t\t\tb c ", Retab('', 4))
38+
call assert_equal("\t\ta\t\t\tb\t\t c\t ", Retab('!', 4))
39+
40+
call assert_equal(" a\t\tb c ", Retab('', 10))
41+
call assert_equal(" a\t\tb c ", Retab('!', 10))
42+
43+
set tabstop=8 expandtab
44+
call assert_equal(" a b c ", Retab('', ''))
45+
call assert_equal(" a b c ", Retab('', 0))
46+
call assert_equal(" a b c ", Retab('', 8))
47+
call assert_equal(" a b c ", Retab('!', ''))
48+
call assert_equal(" a b c ", Retab('!', 0))
49+
call assert_equal(" a b c ", Retab('!', 8))
50+
51+
call assert_equal(" a b c ", Retab(' ', 4))
52+
call assert_equal(" a b c ", Retab('!', 4))
53+
54+
call assert_equal(" a b c ", Retab(' ', 10))
55+
call assert_equal(" a b c ", Retab('!', 10))
56+
57+
set tabstop=4 noexpandtab
58+
call assert_equal("\ta\t\tb c ", Retab('', ''))
59+
call assert_equal("\ta\t\tb\t\t c\t ", Retab('!', ''))
60+
call assert_equal("\t a\t\t\tb c ", Retab('', 3))
61+
call assert_equal("\t a\t\t\tb\t\t\tc\t ", Retab('!', 3))
62+
call assert_equal(" a\t b c ", Retab('', 5))
63+
call assert_equal(" a\t b\t\t c\t ", Retab('!', 5))
64+
65+
set tabstop=4 expandtab
66+
call assert_equal(" a b c ", Retab('', ''))
67+
call assert_equal(" a b c ", Retab('!', ''))
68+
call assert_equal(" a b c ", Retab('', 3))
69+
call assert_equal(" a b c ", Retab('!', 3))
70+
call assert_equal(" a b c ", Retab('', 5))
71+
call assert_equal(" a b c ", Retab('!', 5))
72+
endfunc
73+
74+
func Test_retab_error()
75+
call assert_fails('retab -1', 'E487:')
76+
call assert_fails('retab! -1', 'E487:')
77+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
206,
767769
/**/
768770
205,
769771
/**/

0 commit comments

Comments
 (0)