blob: 199cdd45c71c49e97f72dd910ae6fa3cde1e23f3 [file] [log] [blame]
Bram Moolenaar8f79acd2016-01-01 14:48:20 +01001" Tests for the :set command
2
3function Test_set_backslash()
4 let isk_save = &isk
5
6 set isk=a,b,c
7 set isk+=d
8 call assert_equal('a,b,c,d', &isk)
9 set isk+=\\,e
10 call assert_equal('a,b,c,d,\,e', &isk)
11 set isk-=e
12 call assert_equal('a,b,c,d,\', &isk)
13 set isk-=\\
14 call assert_equal('a,b,c,d', &isk)
15
16 let &isk = isk_save
17endfunction
18
19function Test_set_add()
20 let wig_save = &wig
21
22 set wildignore=*.png,
23 set wildignore+=*.jpg
24 call assert_equal('*.png,*.jpg', &wig)
25
26 let &wig = wig_save
27endfunction
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +020028
Dominique Pelle042414f2021-07-12 21:43:19 +020029
30" :set, :setlocal, :setglobal without arguments show values of options.
31func Test_set_no_arg()
32 set textwidth=79
33 let a = execute('set')
34 call assert_match("^\n--- Options ---\n.*textwidth=79\\>", a)
35 set textwidth&
36
37 setlocal textwidth=78
38 let a = execute('setlocal')
39 call assert_match("^\n--- Local option values ---\n.*textwidth=78\\>", a)
40 setlocal textwidth&
41
42 setglobal textwidth=77
43 let a = execute('setglobal')
44 call assert_match("^\n--- Global option values ---\n.*textwidth=77\\>", a)
45 setglobal textwidth&
46endfunc
47
Bram Moolenaar15a24f02021-12-03 20:43:24 +000048func Test_set_termcap()
49 CheckNotGui
50
51 let lines = split(execute('set termcap'), "\n")
52 call assert_match('--- Terminal codes ---', lines[0])
53 " four columns
54 call assert_match('t_..=.*t_..=.*t_..=.*t_..=', lines[1])
55
56 for keys_idx in range(len(lines))
57 if lines[keys_idx] =~ '--- Terminal keys ---'
58 break
59 endif
60 endfor
61 call assert_true(keys_idx < len(lines))
62 " three columns
Bram Moolenaarcd2f8f02021-12-03 21:18:14 +000063 call assert_match('<[^>]*> .*<[^>]*> .*<[^>]*> ', lines[keys_idx + 1])
Bram Moolenaar15a24f02021-12-03 20:43:24 +000064
65 let more_lines = split(execute('set! termcap'), "\n")
66 for i in range(len(more_lines))
67 if more_lines[i] =~ '--- Terminal keys ---'
68 break
69 endif
70 endfor
71 call assert_true(i < len(more_lines))
72 call assert_true(i > keys_idx)
73 call assert_true(len(more_lines) - i > len(lines) - keys_idx)
74endfunc
75
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +020076" vim: shiftwidth=2 sts=2 expandtab