blob: c5dbb9f4c47b7b6081a295d64950ca7359b01eb4 [file] [log] [blame]
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02001" Test for options
2
Bram Moolenaar1e115362019-01-09 23:01:02 +01003func Test_whichwrap()
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02004 set whichwrap=b,s
5 call assert_equal('b,s', &whichwrap)
6
7 set whichwrap+=h,l
8 call assert_equal('b,s,h,l', &whichwrap)
9
10 set whichwrap+=h,l
11 call assert_equal('b,s,h,l', &whichwrap)
12
13 set whichwrap+=h,l
14 call assert_equal('b,s,h,l', &whichwrap)
15
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +010016 set whichwrap=h,h
17 call assert_equal('h', &whichwrap)
18
19 set whichwrap=h,h,h
20 call assert_equal('h', &whichwrap)
21
Bram Moolenaarc8ce6152016-08-07 13:48:20 +020022 set whichwrap&
Bram Moolenaar1e115362019-01-09 23:01:02 +010023endfunc
Bram Moolenaarc8ce6152016-08-07 13:48:20 +020024
Bram Moolenaar1e115362019-01-09 23:01:02 +010025func Test_isfname()
Bram Moolenaar187a4f22017-02-23 17:07:14 +010026 " This used to cause Vim to access uninitialized memory.
27 set isfname=
28 call assert_equal("~X", expand("~X"))
29 set isfname&
Bram Moolenaar1e115362019-01-09 23:01:02 +010030endfunc
Bram Moolenaar187a4f22017-02-23 17:07:14 +010031
Bram Moolenaar1e115362019-01-09 23:01:02 +010032func Test_wildchar()
Bram Moolenaara12e4032017-02-25 21:37:57 +010033 " Empty 'wildchar' used to access invalid memory.
34 call assert_fails('set wildchar=', 'E521:')
35 call assert_fails('set wildchar=abc', 'E521:')
36 set wildchar=<Esc>
37 let a=execute('set wildchar?')
38 call assert_equal("\n wildchar=<Esc>", a)
39 set wildchar=27
40 let a=execute('set wildchar?')
41 call assert_equal("\n wildchar=<Esc>", a)
42 set wildchar&
Bram Moolenaar1e115362019-01-09 23:01:02 +010043endfunc
Bram Moolenaara12e4032017-02-25 21:37:57 +010044
Bram Moolenaar1e115362019-01-09 23:01:02 +010045func Test_options()
Bram Moolenaarc8ce6152016-08-07 13:48:20 +020046 let caught = 'ok'
47 try
48 options
49 catch
50 let caught = v:throwpoint . "\n" . v:exception
51 endtry
52 call assert_equal('ok', caught)
53
54 " close option-window
55 close
Bram Moolenaar1e115362019-01-09 23:01:02 +010056endfunc
Bram Moolenaarc8ce6152016-08-07 13:48:20 +020057
Bram Moolenaar1e115362019-01-09 23:01:02 +010058func Test_path_keep_commas()
Bram Moolenaarc8ce6152016-08-07 13:48:20 +020059 " Test that changing 'path' keeps two commas.
60 set path=foo,,bar
61 set path-=bar
62 set path+=bar
63 call assert_equal('foo,,bar', &path)
64
65 set path&
Bram Moolenaar1e115362019-01-09 23:01:02 +010066endfunc
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020067
68func Test_signcolumn()
Bram Moolenaarebcccad2016-08-12 19:17:13 +020069 if has('signs')
70 call assert_equal("auto", &signcolumn)
71 set signcolumn=yes
72 set signcolumn=no
73 call assert_fails('set signcolumn=nope')
74 endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020075endfunc
76
Bram Moolenaard0b51382016-11-04 15:23:45 +010077func Test_filetype_valid()
78 set ft=valid_name
79 call assert_equal("valid_name", &filetype)
80 set ft=valid-name
81 call assert_equal("valid-name", &filetype)
82
83 call assert_fails(":set ft=wrong;name", "E474:")
84 call assert_fails(":set ft=wrong\\\\name", "E474:")
85 call assert_fails(":set ft=wrong\\|name", "E474:")
86 call assert_fails(":set ft=wrong/name", "E474:")
87 call assert_fails(":set ft=wrong\\\nname", "E474:")
88 call assert_equal("valid-name", &filetype)
89
90 exe "set ft=trunc\x00name"
91 call assert_equal("trunc", &filetype)
92endfunc
93
94func Test_syntax_valid()
Bram Moolenaar9376f5f2016-11-04 16:41:20 +010095 if !has('syntax')
96 return
97 endif
Bram Moolenaard0b51382016-11-04 15:23:45 +010098 set syn=valid_name
99 call assert_equal("valid_name", &syntax)
100 set syn=valid-name
101 call assert_equal("valid-name", &syntax)
102
103 call assert_fails(":set syn=wrong;name", "E474:")
104 call assert_fails(":set syn=wrong\\\\name", "E474:")
105 call assert_fails(":set syn=wrong\\|name", "E474:")
106 call assert_fails(":set syn=wrong/name", "E474:")
107 call assert_fails(":set syn=wrong\\\nname", "E474:")
108 call assert_equal("valid-name", &syntax)
109
110 exe "set syn=trunc\x00name"
111 call assert_equal("trunc", &syntax)
112endfunc
113
114func Test_keymap_valid()
Bram Moolenaar9376f5f2016-11-04 16:41:20 +0100115 if !has('keymap')
116 return
117 endif
Bram Moolenaard0b51382016-11-04 15:23:45 +0100118 call assert_fails(":set kmp=valid_name", "E544:")
119 call assert_fails(":set kmp=valid_name", "valid_name")
120 call assert_fails(":set kmp=valid-name", "E544:")
121 call assert_fails(":set kmp=valid-name", "valid-name")
122
123 call assert_fails(":set kmp=wrong;name", "E474:")
124 call assert_fails(":set kmp=wrong\\\\name", "E474:")
125 call assert_fails(":set kmp=wrong\\|name", "E474:")
126 call assert_fails(":set kmp=wrong/name", "E474:")
127 call assert_fails(":set kmp=wrong\\\nname", "E474:")
128
129 call assert_fails(":set kmp=trunc\x00name", "E544:")
130 call assert_fails(":set kmp=trunc\x00name", "trunc")
131endfunc
Bram Moolenaar7554da42016-11-25 22:04:13 +0100132
Bram Moolenaarf422bcc2016-11-26 17:45:53 +0100133func Check_dir_option(name)
Bram Moolenaar7554da42016-11-25 22:04:13 +0100134 " Check that it's possible to set the option.
Bram Moolenaarf422bcc2016-11-26 17:45:53 +0100135 exe 'set ' . a:name . '=/usr/share/dict/words'
136 call assert_equal('/usr/share/dict/words', eval('&' . a:name))
137 exe 'set ' . a:name . '=/usr/share/dict/words,/and/there'
138 call assert_equal('/usr/share/dict/words,/and/there', eval('&' . a:name))
139 exe 'set ' . a:name . '=/usr/share/dict\ words'
140 call assert_equal('/usr/share/dict words', eval('&' . a:name))
Bram Moolenaar7554da42016-11-25 22:04:13 +0100141
142 " Check rejecting weird characters.
Bram Moolenaarf422bcc2016-11-26 17:45:53 +0100143 call assert_fails("set " . a:name . "=/not&there", "E474:")
144 call assert_fails("set " . a:name . "=/not>there", "E474:")
145 call assert_fails("set " . a:name . "=/not.*there", "E474:")
146endfunc
147
Bram Moolenaar60629d62017-02-23 18:08:56 +0100148func Test_cinkeys()
149 " This used to cause invalid memory access
150 set cindent cinkeys=0
151 norm a
152 set cindent& cinkeys&
153endfunc
154
Bram Moolenaarf422bcc2016-11-26 17:45:53 +0100155func Test_dictionary()
156 call Check_dir_option('dictionary')
157endfunc
158
159func Test_thesaurus()
160 call Check_dir_option('thesaurus')
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100161endfun
162
Bram Moolenaar226c5342017-02-17 14:53:15 +0100163func Test_complete()
164 " Trailing single backslash used to cause invalid memory access.
165 set complete=s\
166 new
167 call feedkeys("i\<C-N>\<Esc>", 'xt')
168 bwipe!
169 set complete&
170endfun
171
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100172func Test_set_completion()
173 call feedkeys(":set di\<C-A>\<C-B>\"\<CR>", 'tx')
174 call assert_equal('"set dictionary diff diffexpr diffopt digraph directory display', @:)
175
176 " Expand boolan options. When doing :set no<Tab>
177 " vim displays the options names without "no" but completion uses "no...".
178 call feedkeys(":set nodi\<C-A>\<C-B>\"\<CR>", 'tx')
179 call assert_equal('"set nodiff digraph', @:)
180
181 call feedkeys(":set invdi\<C-A>\<C-B>\"\<CR>", 'tx')
182 call assert_equal('"set invdiff digraph', @:)
183
184 " Expand abbreviation of options.
185 call feedkeys(":set ts\<C-A>\<C-B>\"\<CR>", 'tx')
186 call assert_equal('"set tabstop thesaurus ttyscroll', @:)
187
188 " Expand current value
189 call feedkeys(":set fileencodings=\<C-A>\<C-B>\"\<CR>", 'tx')
190 call assert_equal('"set fileencodings=ucs-bom,utf-8,default,latin1', @:)
191
192 call feedkeys(":set fileencodings:\<C-A>\<C-B>\"\<CR>", 'tx')
193 call assert_equal('"set fileencodings:ucs-bom,utf-8,default,latin1', @:)
194
195 " Expand key codes.
196 call feedkeys(":set <H\<C-A>\<C-B>\"\<CR>", 'tx')
197 call assert_equal('"set <Help> <Home>', @:)
198
199 " Expand terminal options.
200 call feedkeys(":set t_A\<C-A>\<C-B>\"\<CR>", 'tx')
201 call assert_equal('"set t_AB t_AF t_AL', @:)
202
203 " Expand directories.
204 call feedkeys(":set cdpath=./\<C-A>\<C-B>\"\<CR>", 'tx')
205 call assert_match(' ./samples/ ', @:)
206 call assert_notmatch(' ./small.vim ', @:)
207
208 " Expand files and directories.
209 call feedkeys(":set tags=./\<C-A>\<C-B>\"\<CR>", 'tx')
210 call assert_match(' ./samples/.* ./small.vim', @:)
211
212 call feedkeys(":set tags=./\\\\ dif\<C-A>\<C-B>\"\<CR>", 'tx')
213 call assert_equal('"set tags=./\\ diff diffexpr diffopt', @:)
214endfunc
215
216func Test_set_errors()
217 call assert_fails('set scroll=-1', 'E49:')
218 call assert_fails('set backupcopy=', 'E474:')
219 call assert_fails('set regexpengine=3', 'E474:')
220 call assert_fails('set history=10001', 'E474:')
221 call assert_fails('set numberwidth=11', 'E474:')
222 call assert_fails('set colorcolumn=-a')
223 call assert_fails('set colorcolumn=a')
224 call assert_fails('set colorcolumn=1,')
225 call assert_fails('set cmdheight=-1', 'E487:')
226 call assert_fails('set cmdwinheight=-1', 'E487:')
227 if has('conceal')
228 call assert_fails('set conceallevel=-1', 'E487:')
229 call assert_fails('set conceallevel=4', 'E474:')
230 endif
231 call assert_fails('set helpheight=-1', 'E487:')
232 call assert_fails('set history=-1', 'E487:')
233 call assert_fails('set report=-1', 'E487:')
234 call assert_fails('set shiftwidth=-1', 'E487:')
235 call assert_fails('set sidescroll=-1', 'E487:')
236 call assert_fails('set tabstop=-1', 'E487:')
237 call assert_fails('set textwidth=-1', 'E487:')
238 call assert_fails('set timeoutlen=-1', 'E487:')
239 call assert_fails('set updatecount=-1', 'E487:')
240 call assert_fails('set updatetime=-1', 'E487:')
241 call assert_fails('set winheight=-1', 'E487:')
242 call assert_fails('set tabstop!', 'E488:')
243 call assert_fails('set xxx', 'E518:')
244 call assert_fails('set beautify?', 'E519:')
245 call assert_fails('set undolevels=x', 'E521:')
246 call assert_fails('set tabstop=', 'E521:')
247 call assert_fails('set comments=-', 'E524:')
248 call assert_fails('set comments=a', 'E525:')
249 call assert_fails('set foldmarker=x', 'E536:')
250 call assert_fails('set commentstring=x', 'E537:')
251 call assert_fails('set complete=x', 'E539:')
252 call assert_fails('set statusline=%{', 'E540:')
253 call assert_fails('set statusline=' . repeat("%p", 81), 'E541:')
254 call assert_fails('set statusline=%(', 'E542:')
Bram Moolenaar24922ec2017-02-23 17:59:22 +0100255 if has('cursorshape')
256 " This invalid value for 'guicursor' used to cause Vim to crash.
257 call assert_fails('set guicursor=i-ci,r-cr:h', 'E545:')
258 call assert_fails('set guicursor=i-ci', 'E545:')
259 call assert_fails('set guicursor=x', 'E545:')
260 call assert_fails('set guicursor=r-cr:horx', 'E548:')
261 call assert_fails('set guicursor=r-cr:hor0', 'E549:')
262 endif
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100263 call assert_fails('set backupext=~ patchmode=~', 'E589:')
264 call assert_fails('set winminheight=10 winheight=9', 'E591:')
265 call assert_fails('set winminwidth=10 winwidth=9', 'E592:')
266 call assert_fails("set showbreak=\x01", 'E595:')
267 call assert_fails('set t_foo=', 'E846:')
Bram Moolenaar7554da42016-11-25 22:04:13 +0100268endfunc
Bram Moolenaar67391142017-02-19 21:07:04 +0100269
Bram Moolenaar35bc7d62018-10-02 14:45:10 +0200270" Must be executed before other tests that set 'term'.
271func Test_000_term_option_verbose()
Bram Moolenaar4f888752018-10-02 15:06:40 +0200272 if has('gui_running')
273 return
274 endif
Bram Moolenaar35bc7d62018-10-02 14:45:10 +0200275 let verb_cm = execute('verbose set t_cm')
276 call assert_notmatch('Last set from', verb_cm)
277
278 let term_save = &term
279 set term=ansi
280 let verb_cm = execute('verbose set t_cm')
281 call assert_match('Last set from.*test_options.vim', verb_cm)
282 let &term = term_save
283endfunc
284
Bram Moolenaar67391142017-02-19 21:07:04 +0100285func Test_set_ttytype()
286 if !has('gui_running') && has('unix')
287 " Setting 'ttytype' used to cause a double-free when exiting vim and
288 " when vim is compiled with -DEXITFREE.
289 set ttytype=ansi
290 call assert_equal('ansi', &ttytype)
291 call assert_equal(&ttytype, &term)
292 set ttytype=xterm
293 call assert_equal('xterm', &ttytype)
294 call assert_equal(&ttytype, &term)
Bram Moolenaarf803a762017-04-09 22:54:13 +0200295 " "set ttytype=" gives E522 instead of E529
296 " in travis on some builds. Why? Catch both for now
297 try
298 set ttytype=
Bram Moolenaar69e05692018-05-10 14:11:52 +0200299 call assert_report('set ttytype= did not fail')
Bram Moolenaarf803a762017-04-09 22:54:13 +0200300 catch /E529\|E522/
301 endtry
302
303 " Some systems accept any terminal name and return dumb settings,
304 " check for failure of finding the entry and for missing 'cm' entry.
305 try
306 set ttytype=xxx
Bram Moolenaar69e05692018-05-10 14:11:52 +0200307 call assert_report('set ttytype=xxx did not fail')
Bram Moolenaarf803a762017-04-09 22:54:13 +0200308 catch /E522\|E437/
309 endtry
310
Bram Moolenaar67391142017-02-19 21:07:04 +0100311 set ttytype&
312 call assert_equal(&ttytype, &term)
313 endif
314endfunc
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100315
316func Test_set_all()
317 set tw=75
318 set iskeyword=a-z,A-Z
319 set nosplitbelow
320 let out = execute('set all')
321 call assert_match('textwidth=75', out)
322 call assert_match('iskeyword=a-z,A-Z', out)
323 call assert_match('nosplitbelow', out)
324 set tw& iskeyword& splitbelow&
325endfunc
326
327func Test_set_values()
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100328 if filereadable('opt_test.vim')
329 source opt_test.vim
Bram Moolenaare8512d72017-03-07 22:33:32 +0100330 else
331 throw 'Skipped: opt_test.vim does not exist'
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100332 endif
333endfunc
Bram Moolenaara701b3b2017-04-20 22:57:27 +0200334
335func ResetIndentexpr()
336 set indentexpr=
337endfunc
338
339func Test_set_indentexpr()
340 " this was causing usage of freed memory
341 set indentexpr=ResetIndentexpr()
342 new
343 call feedkeys("i\<c-f>", 'x')
344 call assert_equal('', &indentexpr)
345 bwipe!
346endfunc
Bram Moolenaarb8e22a02018-04-12 21:37:34 +0200347
348func Test_backupskip()
Bram Moolenaar98ad1e12019-01-30 21:51:27 +0100349 " Option 'backupskip' may contain several comma-separated path
350 " specifications if one or more of the environment variables TMPDIR, TMP,
351 " or TEMP is defined. To simplify testing, convert the string value into a
352 " list.
353 let bsklist = split(&bsk, ',')
354
Bram Moolenaarb8e22a02018-04-12 21:37:34 +0200355 if has("mac")
Bram Moolenaar98ad1e12019-01-30 21:51:27 +0100356 let found = (index(bsklist, '/private/tmp/*') >= 0)
357 call assert_true(found, '/private/tmp not in option bsk: ' . &bsk)
Bram Moolenaarb8e22a02018-04-12 21:37:34 +0200358 elseif has("unix")
Bram Moolenaar98ad1e12019-01-30 21:51:27 +0100359 let found = (index(bsklist, '/tmp/*') >= 0)
360 call assert_true(found, '/tmp not in option bsk: ' . &bsk)
Bram Moolenaarb8e22a02018-04-12 21:37:34 +0200361 endif
362
Bram Moolenaar98ad1e12019-01-30 21:51:27 +0100363 " If our test platform is Windows, the path(s) in option bsk will use
364 " backslash for the path separator and the components could be in short
365 " (8.3) format. As such, we need to replace the backslashes with forward
366 " slashes and convert the path components to long format. The expand()
367 " function will do this but it cannot handle comma-separated paths. This is
368 " why bsk was converted from a string into a list of strings above.
369 "
370 " One final complication is that the wildcard "/*" is at the end of each
371 " path and so expand() might return a list of matching files. To prevent
372 " this, we need to remove the wildcard before calling expand() and then
373 " append it afterwards.
374 if has('win32')
375 let item_nbr = 0
376 while item_nbr < len(bsklist)
377 let path_spec = bsklist[item_nbr]
378 let path_spec = strcharpart(path_spec, 0, strlen(path_spec)-2)
379 let path_spec = substitute(expand(path_spec), '\\', '/', 'g')
380 let bsklist[item_nbr] = path_spec . '/*'
381 let item_nbr += 1
382 endwhile
383 endif
384
385 " Option bsk will also include these environment variables if defined.
386 " If they're defined, verify they appear in the option value.
387 for var in ['$TMPDIR', '$TMP', '$TEMP']
Bram Moolenaarb8e22a02018-04-12 21:37:34 +0200388 if exists(var)
389 let varvalue = substitute(expand(var), '\\', '/', 'g')
Bram Moolenaarcbbd0f62019-01-30 22:36:18 +0100390 let varvalue = substitute(varvalue, '/$', '', '')
391 let varvalue .= '/*'
392 let found = (index(bsklist, varvalue) >= 0)
393 call assert_true(found, var . ' (' . varvalue . ') not in option bsk: ' . &bsk)
Bram Moolenaarb8e22a02018-04-12 21:37:34 +0200394 endif
395 endfor
396endfunc
Bram Moolenaar25782a72018-05-13 18:05:33 +0200397
398func Test_copy_winopt()
Bram Moolenaar7cb33a12018-08-23 22:20:35 +0200399 set hidden
Bram Moolenaar25782a72018-05-13 18:05:33 +0200400
Bram Moolenaar7cb33a12018-08-23 22:20:35 +0200401 " Test copy option from current buffer in window
402 split
403 enew
404 setlocal numberwidth=5
405 wincmd w
406 call assert_equal(4,&numberwidth)
407 bnext
408 call assert_equal(5,&numberwidth)
409 bw!
410 call assert_equal(4,&numberwidth)
Bram Moolenaar25782a72018-05-13 18:05:33 +0200411
Bram Moolenaar7cb33a12018-08-23 22:20:35 +0200412 " Test copy value from window that used to be display the buffer
413 split
414 enew
415 setlocal numberwidth=6
416 bnext
417 wincmd w
418 call assert_equal(4,&numberwidth)
419 bnext
420 call assert_equal(6,&numberwidth)
421 bw!
Bram Moolenaar25782a72018-05-13 18:05:33 +0200422
Bram Moolenaar7cb33a12018-08-23 22:20:35 +0200423 " Test that if buffer is current, don't use the stale cached value
424 " from the last time the buffer was displayed.
425 split
426 enew
427 setlocal numberwidth=7
428 bnext
429 bnext
430 setlocal numberwidth=8
431 wincmd w
432 call assert_equal(4,&numberwidth)
433 bnext
434 call assert_equal(8,&numberwidth)
435 bw!
Bram Moolenaar25782a72018-05-13 18:05:33 +0200436
Bram Moolenaar7cb33a12018-08-23 22:20:35 +0200437 " Test value is not copied if window already has seen the buffer
438 enew
439 split
440 setlocal numberwidth=9
441 bnext
442 setlocal numberwidth=10
443 wincmd w
444 call assert_equal(4,&numberwidth)
445 bnext
446 call assert_equal(4,&numberwidth)
447 bw!
448
449 set hidden&
Bram Moolenaar25782a72018-05-13 18:05:33 +0200450endfunc
Bram Moolenaarfc089602018-06-24 16:53:35 +0200451
452func Test_shortmess_F()
453 new
454 call assert_match('\[No Name\]', execute('file'))
455 set shortmess+=F
456 call assert_match('\[No Name\]', execute('file'))
457 call assert_match('^\s*$', execute('file foo'))
458 call assert_match('foo', execute('file'))
459 set shortmess-=F
460 call assert_match('bar', execute('file bar'))
461 call assert_match('bar', execute('file'))
462 set shortmess&
463 bwipe
464endfunc
Bram Moolenaar2f0f8712018-08-21 18:50:18 +0200465
466func Test_shortmess_F2()
467 e file1
468 e file2
469 call assert_match('file1', execute('bn', ''))
470 call assert_match('file2', execute('bn', ''))
471 set shortmess+=F
472 call assert_true(empty(execute('bn', '')))
Bram Moolenaareda65222019-05-16 20:29:44 +0200473 call assert_false(test_getvalue('need_fileinfo'))
Bram Moolenaar2f0f8712018-08-21 18:50:18 +0200474 call assert_true(empty(execute('bn', '')))
Bram Moolenaareda65222019-05-16 20:29:44 +0200475 call assert_false(test_getvalue('need_fileinfo'))
Bram Moolenaar2f0f8712018-08-21 18:50:18 +0200476 set hidden
477 call assert_true(empty(execute('bn', '')))
Bram Moolenaareda65222019-05-16 20:29:44 +0200478 call assert_false(test_getvalue('need_fileinfo'))
Bram Moolenaar2f0f8712018-08-21 18:50:18 +0200479 call assert_true(empty(execute('bn', '')))
Bram Moolenaareda65222019-05-16 20:29:44 +0200480 call assert_false(test_getvalue('need_fileinfo'))
Bram Moolenaar2f0f8712018-08-21 18:50:18 +0200481 set nohidden
482 call assert_true(empty(execute('bn', '')))
Bram Moolenaareda65222019-05-16 20:29:44 +0200483 call assert_false(test_getvalue('need_fileinfo'))
Bram Moolenaar2f0f8712018-08-21 18:50:18 +0200484 call assert_true(empty(execute('bn', '')))
Bram Moolenaareda65222019-05-16 20:29:44 +0200485 call assert_false(test_getvalue('need_fileinfo'))
Bram Moolenaar2f0f8712018-08-21 18:50:18 +0200486 set shortmess&
487 call assert_match('file1', execute('bn', ''))
488 call assert_match('file2', execute('bn', ''))
489 bwipe
490 bwipe
491endfunc
Bram Moolenaar375e3392019-01-31 18:26:10 +0100492
493func Test_local_scrolloff()
494 set so=5
495 set siso=7
496 split
497 call assert_equal(5, &so)
498 setlocal so=3
499 call assert_equal(3, &so)
500 wincmd w
501 call assert_equal(5, &so)
502 wincmd w
503 setlocal so<
504 call assert_equal(5, &so)
505 setlocal so=0
506 call assert_equal(0, &so)
507 setlocal so=-1
508 call assert_equal(5, &so)
509
510 call assert_equal(7, &siso)
511 setlocal siso=3
512 call assert_equal(3, &siso)
513 wincmd w
514 call assert_equal(7, &siso)
515 wincmd w
516 setlocal siso<
517 call assert_equal(7, &siso)
518 setlocal siso=0
519 call assert_equal(0, &siso)
520 setlocal siso=-1
521 call assert_equal(7, &siso)
522
523 close
524 set so&
525 set siso&
526endfunc
Bram Moolenaar449ac472019-04-03 21:42:35 +0200527
528func Test_writedelay()
529 if !has('reltime')
530 return
531 endif
532 new
533 call setline(1, 'empty')
534 redraw
535 set writedelay=10
536 let start = reltime()
537 call setline(1, repeat('x', 70))
538 redraw
539 let elapsed = reltimefloat(reltime(start))
540 set writedelay=0
541 " With 'writedelay' set should take at least 30 * 10 msec
542 call assert_inrange(30 * 0.01, 999.0, elapsed)
543
544 bwipe!
Bram Moolenaarb4e6a2d2019-04-03 21:53:33 +0200545endfunc
546
547func Test_visualbell()
Bram Moolenaar7a666272019-04-03 22:52:34 +0200548 set belloff=
Bram Moolenaarb4e6a2d2019-04-03 21:53:33 +0200549 set visualbell
550 call assert_beeps('normal 0h')
551 set novisualbell
Bram Moolenaar7a666272019-04-03 22:52:34 +0200552 set belloff=all
Bram Moolenaar449ac472019-04-03 21:42:35 +0200553endfunc