blob: 7fbba96c6669ce3c50d41ddc45b0751df2afdef4 [file] [log] [blame]
Bram Moolenaar27a82e32016-01-02 21:39:09 +01001" 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
13func 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)
Bram Moolenaare9c07272016-03-30 20:50:46 +020056 set nocompatible viminfo+=nviminfo
Bram Moolenaar27a82e32016-01-02 21:39:09 +010057endfunc
58
59" vim: tabstop=2 shiftwidth=0 expandtab