Skip to content

Commit 27a82e3

Browse files
committed
Add new file left out from patch 7.4.1034.
1 parent aac624b commit 27a82e3

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

src/testdir/test_backspace_opt.vim

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
" Tests for 'backspace' settings
2+
3+
:func Exec(expr)
4+
let str=''
5+
try
6+
exec a:expr
7+
catch /.*/
8+
let str=v:exception
9+
endtry
10+
return str
11+
:endfunc
12+
13+
func Test_backspace_option()
14+
set backspace=
15+
call assert_equal('', &backspace)
16+
set backspace=indent
17+
call assert_equal('indent', &backspace)
18+
set backspace=eol
19+
call assert_equal('eol', &backspace)
20+
set backspace=start
21+
call assert_equal('start', &backspace)
22+
" Add the value
23+
set backspace=
24+
set backspace=indent
25+
call assert_equal('indent', &backspace)
26+
set backspace+=eol
27+
call assert_equal('indent,eol', &backspace)
28+
set backspace+=start
29+
call assert_equal('indent,eol,start', &backspace)
30+
" Delete the value
31+
set backspace-=indent
32+
call assert_equal('eol,start', &backspace)
33+
set backspace-=start
34+
call assert_equal('eol', &backspace)
35+
set backspace-=eol
36+
call assert_equal('', &backspace)
37+
" Check the error
38+
call assert_equal(0, match(Exec('set backspace=ABC'), '.*E474'))
39+
call assert_equal(0, match(Exec('set backspace+=def'), '.*E474'))
40+
" NOTE: Vim doesn't check following error...
41+
"call assert_equal(0, match(Exec('set backspace-=ghi'), '.*E474'))
42+
43+
" Check backwards compatibility with version 5.4 and earlier
44+
set backspace=0
45+
call assert_equal('0', &backspace)
46+
set backspace=1
47+
call assert_equal('1', &backspace)
48+
set backspace=2
49+
call assert_equal('2', &backspace)
50+
call assert_false(match(Exec('set backspace=3'), '.*E474'))
51+
call assert_false(match(Exec('set backspace=10'), '.*E474'))
52+
53+
" Cleared when 'compatible' is set
54+
set compatible
55+
call assert_equal('', &backspace)
56+
endfunc
57+
58+
" vim: tabstop=2 shiftwidth=0 expandtab

0 commit comments

Comments
 (0)