blob: 13de719342338ad79cc3d414de4be3fae9789cf3 [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
Bram Moolenaare0b59492019-05-21 20:54:45 +020054 " Check if the option-window is opened horizontally.
55 wincmd j
56 call assert_notequal('option-window', bufname(''))
57 wincmd k
58 call assert_equal('option-window', bufname(''))
59 " close option-window
60 close
61
62 " Open the option-window vertically.
63 vert options
64 " Check if the option-window is opened vertically.
65 wincmd l
66 call assert_notequal('option-window', bufname(''))
67 wincmd h
68 call assert_equal('option-window', bufname(''))
69 " close option-window
70 close
71
72 " Open the option-window in a new tab.
73 tab options
74 " Check if the option-window is opened in a tab.
75 normal gT
76 call assert_notequal('option-window', bufname(''))
77 normal gt
78 call assert_equal('option-window', bufname(''))
79
Bram Moolenaarc8ce6152016-08-07 13:48:20 +020080 " close option-window
81 close
Bram Moolenaar1e115362019-01-09 23:01:02 +010082endfunc
Bram Moolenaarc8ce6152016-08-07 13:48:20 +020083
Bram Moolenaar1e115362019-01-09 23:01:02 +010084func Test_path_keep_commas()
Bram Moolenaarc8ce6152016-08-07 13:48:20 +020085 " Test that changing 'path' keeps two commas.
86 set path=foo,,bar
87 set path-=bar
88 set path+=bar
89 call assert_equal('foo,,bar', &path)
90
91 set path&
Bram Moolenaar1e115362019-01-09 23:01:02 +010092endfunc
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020093
94func Test_signcolumn()
Bram Moolenaarebcccad2016-08-12 19:17:13 +020095 if has('signs')
96 call assert_equal("auto", &signcolumn)
97 set signcolumn=yes
98 set signcolumn=no
99 call assert_fails('set signcolumn=nope')
100 endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +0200101endfunc
102
Bram Moolenaard0b51382016-11-04 15:23:45 +0100103func Test_filetype_valid()
104 set ft=valid_name
105 call assert_equal("valid_name", &filetype)
106 set ft=valid-name
107 call assert_equal("valid-name", &filetype)
108
109 call assert_fails(":set ft=wrong;name", "E474:")
110 call assert_fails(":set ft=wrong\\\\name", "E474:")
111 call assert_fails(":set ft=wrong\\|name", "E474:")
112 call assert_fails(":set ft=wrong/name", "E474:")
113 call assert_fails(":set ft=wrong\\\nname", "E474:")
114 call assert_equal("valid-name", &filetype)
115
116 exe "set ft=trunc\x00name"
117 call assert_equal("trunc", &filetype)
118endfunc
119
120func Test_syntax_valid()
Bram Moolenaar9376f5f2016-11-04 16:41:20 +0100121 if !has('syntax')
122 return
123 endif
Bram Moolenaard0b51382016-11-04 15:23:45 +0100124 set syn=valid_name
125 call assert_equal("valid_name", &syntax)
126 set syn=valid-name
127 call assert_equal("valid-name", &syntax)
128
129 call assert_fails(":set syn=wrong;name", "E474:")
130 call assert_fails(":set syn=wrong\\\\name", "E474:")
131 call assert_fails(":set syn=wrong\\|name", "E474:")
132 call assert_fails(":set syn=wrong/name", "E474:")
133 call assert_fails(":set syn=wrong\\\nname", "E474:")
134 call assert_equal("valid-name", &syntax)
135
136 exe "set syn=trunc\x00name"
137 call assert_equal("trunc", &syntax)
138endfunc
139
140func Test_keymap_valid()
Bram Moolenaar9376f5f2016-11-04 16:41:20 +0100141 if !has('keymap')
142 return
143 endif
Bram Moolenaard0b51382016-11-04 15:23:45 +0100144 call assert_fails(":set kmp=valid_name", "E544:")
145 call assert_fails(":set kmp=valid_name", "valid_name")
146 call assert_fails(":set kmp=valid-name", "E544:")
147 call assert_fails(":set kmp=valid-name", "valid-name")
148
149 call assert_fails(":set kmp=wrong;name", "E474:")
150 call assert_fails(":set kmp=wrong\\\\name", "E474:")
151 call assert_fails(":set kmp=wrong\\|name", "E474:")
152 call assert_fails(":set kmp=wrong/name", "E474:")
153 call assert_fails(":set kmp=wrong\\\nname", "E474:")
154
155 call assert_fails(":set kmp=trunc\x00name", "E544:")
156 call assert_fails(":set kmp=trunc\x00name", "trunc")
157endfunc
Bram Moolenaar7554da42016-11-25 22:04:13 +0100158
Bram Moolenaarf422bcc2016-11-26 17:45:53 +0100159func Check_dir_option(name)
Bram Moolenaar7554da42016-11-25 22:04:13 +0100160 " Check that it's possible to set the option.
Bram Moolenaarf422bcc2016-11-26 17:45:53 +0100161 exe 'set ' . a:name . '=/usr/share/dict/words'
162 call assert_equal('/usr/share/dict/words', eval('&' . a:name))
163 exe 'set ' . a:name . '=/usr/share/dict/words,/and/there'
164 call assert_equal('/usr/share/dict/words,/and/there', eval('&' . a:name))
165 exe 'set ' . a:name . '=/usr/share/dict\ words'
166 call assert_equal('/usr/share/dict words', eval('&' . a:name))
Bram Moolenaar7554da42016-11-25 22:04:13 +0100167
168 " Check rejecting weird characters.
Bram Moolenaarf422bcc2016-11-26 17:45:53 +0100169 call assert_fails("set " . a:name . "=/not&there", "E474:")
170 call assert_fails("set " . a:name . "=/not>there", "E474:")
171 call assert_fails("set " . a:name . "=/not.*there", "E474:")
172endfunc
173
Bram Moolenaar60629d62017-02-23 18:08:56 +0100174func Test_cinkeys()
175 " This used to cause invalid memory access
176 set cindent cinkeys=0
177 norm a
178 set cindent& cinkeys&
179endfunc
180
Bram Moolenaarf422bcc2016-11-26 17:45:53 +0100181func Test_dictionary()
182 call Check_dir_option('dictionary')
183endfunc
184
185func Test_thesaurus()
186 call Check_dir_option('thesaurus')
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100187endfun
188
Bram Moolenaar226c5342017-02-17 14:53:15 +0100189func Test_complete()
190 " Trailing single backslash used to cause invalid memory access.
191 set complete=s\
192 new
193 call feedkeys("i\<C-N>\<Esc>", 'xt')
194 bwipe!
195 set complete&
196endfun
197
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100198func Test_set_completion()
199 call feedkeys(":set di\<C-A>\<C-B>\"\<CR>", 'tx')
200 call assert_equal('"set dictionary diff diffexpr diffopt digraph directory display', @:)
201
202 " Expand boolan options. When doing :set no<Tab>
203 " vim displays the options names without "no" but completion uses "no...".
204 call feedkeys(":set nodi\<C-A>\<C-B>\"\<CR>", 'tx')
205 call assert_equal('"set nodiff digraph', @:)
206
207 call feedkeys(":set invdi\<C-A>\<C-B>\"\<CR>", 'tx')
208 call assert_equal('"set invdiff digraph', @:)
209
210 " Expand abbreviation of options.
211 call feedkeys(":set ts\<C-A>\<C-B>\"\<CR>", 'tx')
212 call assert_equal('"set tabstop thesaurus ttyscroll', @:)
213
214 " Expand current value
215 call feedkeys(":set fileencodings=\<C-A>\<C-B>\"\<CR>", 'tx')
216 call assert_equal('"set fileencodings=ucs-bom,utf-8,default,latin1', @:)
217
218 call feedkeys(":set fileencodings:\<C-A>\<C-B>\"\<CR>", 'tx')
219 call assert_equal('"set fileencodings:ucs-bom,utf-8,default,latin1', @:)
220
221 " Expand key codes.
222 call feedkeys(":set <H\<C-A>\<C-B>\"\<CR>", 'tx')
223 call assert_equal('"set <Help> <Home>', @:)
224
225 " Expand terminal options.
226 call feedkeys(":set t_A\<C-A>\<C-B>\"\<CR>", 'tx')
227 call assert_equal('"set t_AB t_AF t_AL', @:)
228
229 " Expand directories.
230 call feedkeys(":set cdpath=./\<C-A>\<C-B>\"\<CR>", 'tx')
231 call assert_match(' ./samples/ ', @:)
232 call assert_notmatch(' ./small.vim ', @:)
233
234 " Expand files and directories.
235 call feedkeys(":set tags=./\<C-A>\<C-B>\"\<CR>", 'tx')
236 call assert_match(' ./samples/.* ./small.vim', @:)
237
238 call feedkeys(":set tags=./\\\\ dif\<C-A>\<C-B>\"\<CR>", 'tx')
239 call assert_equal('"set tags=./\\ diff diffexpr diffopt', @:)
240endfunc
241
242func Test_set_errors()
243 call assert_fails('set scroll=-1', 'E49:')
244 call assert_fails('set backupcopy=', 'E474:')
245 call assert_fails('set regexpengine=3', 'E474:')
246 call assert_fails('set history=10001', 'E474:')
247 call assert_fails('set numberwidth=11', 'E474:')
248 call assert_fails('set colorcolumn=-a')
249 call assert_fails('set colorcolumn=a')
250 call assert_fails('set colorcolumn=1,')
251 call assert_fails('set cmdheight=-1', 'E487:')
252 call assert_fails('set cmdwinheight=-1', 'E487:')
253 if has('conceal')
254 call assert_fails('set conceallevel=-1', 'E487:')
255 call assert_fails('set conceallevel=4', 'E474:')
256 endif
257 call assert_fails('set helpheight=-1', 'E487:')
258 call assert_fails('set history=-1', 'E487:')
259 call assert_fails('set report=-1', 'E487:')
260 call assert_fails('set shiftwidth=-1', 'E487:')
261 call assert_fails('set sidescroll=-1', 'E487:')
262 call assert_fails('set tabstop=-1', 'E487:')
263 call assert_fails('set textwidth=-1', 'E487:')
264 call assert_fails('set timeoutlen=-1', 'E487:')
265 call assert_fails('set updatecount=-1', 'E487:')
266 call assert_fails('set updatetime=-1', 'E487:')
267 call assert_fails('set winheight=-1', 'E487:')
268 call assert_fails('set tabstop!', 'E488:')
269 call assert_fails('set xxx', 'E518:')
270 call assert_fails('set beautify?', 'E519:')
271 call assert_fails('set undolevels=x', 'E521:')
272 call assert_fails('set tabstop=', 'E521:')
273 call assert_fails('set comments=-', 'E524:')
274 call assert_fails('set comments=a', 'E525:')
275 call assert_fails('set foldmarker=x', 'E536:')
276 call assert_fails('set commentstring=x', 'E537:')
277 call assert_fails('set complete=x', 'E539:')
278 call assert_fails('set statusline=%{', 'E540:')
279 call assert_fails('set statusline=' . repeat("%p", 81), 'E541:')
280 call assert_fails('set statusline=%(', 'E542:')
Bram Moolenaar24922ec2017-02-23 17:59:22 +0100281 if has('cursorshape')
282 " This invalid value for 'guicursor' used to cause Vim to crash.
283 call assert_fails('set guicursor=i-ci,r-cr:h', 'E545:')
284 call assert_fails('set guicursor=i-ci', 'E545:')
285 call assert_fails('set guicursor=x', 'E545:')
286 call assert_fails('set guicursor=r-cr:horx', 'E548:')
287 call assert_fails('set guicursor=r-cr:hor0', 'E549:')
288 endif
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100289 call assert_fails('set backupext=~ patchmode=~', 'E589:')
290 call assert_fails('set winminheight=10 winheight=9', 'E591:')
291 call assert_fails('set winminwidth=10 winwidth=9', 'E592:')
292 call assert_fails("set showbreak=\x01", 'E595:')
293 call assert_fails('set t_foo=', 'E846:')
Bram Moolenaar7554da42016-11-25 22:04:13 +0100294endfunc
Bram Moolenaar67391142017-02-19 21:07:04 +0100295
Bram Moolenaar35bc7d62018-10-02 14:45:10 +0200296" Must be executed before other tests that set 'term'.
297func Test_000_term_option_verbose()
Bram Moolenaar4f888752018-10-02 15:06:40 +0200298 if has('gui_running')
299 return
300 endif
Bram Moolenaar35bc7d62018-10-02 14:45:10 +0200301 let verb_cm = execute('verbose set t_cm')
302 call assert_notmatch('Last set from', verb_cm)
303
304 let term_save = &term
305 set term=ansi
306 let verb_cm = execute('verbose set t_cm')
307 call assert_match('Last set from.*test_options.vim', verb_cm)
308 let &term = term_save
309endfunc
310
Bram Moolenaar67391142017-02-19 21:07:04 +0100311func Test_set_ttytype()
312 if !has('gui_running') && has('unix')
313 " Setting 'ttytype' used to cause a double-free when exiting vim and
314 " when vim is compiled with -DEXITFREE.
315 set ttytype=ansi
316 call assert_equal('ansi', &ttytype)
317 call assert_equal(&ttytype, &term)
318 set ttytype=xterm
319 call assert_equal('xterm', &ttytype)
320 call assert_equal(&ttytype, &term)
Bram Moolenaarf803a762017-04-09 22:54:13 +0200321 " "set ttytype=" gives E522 instead of E529
322 " in travis on some builds. Why? Catch both for now
323 try
324 set ttytype=
Bram Moolenaar69e05692018-05-10 14:11:52 +0200325 call assert_report('set ttytype= did not fail')
Bram Moolenaarf803a762017-04-09 22:54:13 +0200326 catch /E529\|E522/
327 endtry
328
329 " Some systems accept any terminal name and return dumb settings,
330 " check for failure of finding the entry and for missing 'cm' entry.
331 try
332 set ttytype=xxx
Bram Moolenaar69e05692018-05-10 14:11:52 +0200333 call assert_report('set ttytype=xxx did not fail')
Bram Moolenaarf803a762017-04-09 22:54:13 +0200334 catch /E522\|E437/
335 endtry
336
Bram Moolenaar67391142017-02-19 21:07:04 +0100337 set ttytype&
338 call assert_equal(&ttytype, &term)
339 endif
340endfunc
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100341
342func Test_set_all()
343 set tw=75
344 set iskeyword=a-z,A-Z
345 set nosplitbelow
346 let out = execute('set all')
347 call assert_match('textwidth=75', out)
348 call assert_match('iskeyword=a-z,A-Z', out)
349 call assert_match('nosplitbelow', out)
350 set tw& iskeyword& splitbelow&
351endfunc
352
353func Test_set_values()
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100354 if filereadable('opt_test.vim')
355 source opt_test.vim
Bram Moolenaare8512d72017-03-07 22:33:32 +0100356 else
357 throw 'Skipped: opt_test.vim does not exist'
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100358 endif
359endfunc
Bram Moolenaara701b3b2017-04-20 22:57:27 +0200360
361func ResetIndentexpr()
362 set indentexpr=
363endfunc
364
365func Test_set_indentexpr()
366 " this was causing usage of freed memory
367 set indentexpr=ResetIndentexpr()
368 new
369 call feedkeys("i\<c-f>", 'x')
370 call assert_equal('', &indentexpr)
371 bwipe!
372endfunc
Bram Moolenaarb8e22a02018-04-12 21:37:34 +0200373
374func Test_backupskip()
Bram Moolenaar98ad1e12019-01-30 21:51:27 +0100375 " Option 'backupskip' may contain several comma-separated path
376 " specifications if one or more of the environment variables TMPDIR, TMP,
377 " or TEMP is defined. To simplify testing, convert the string value into a
378 " list.
379 let bsklist = split(&bsk, ',')
380
Bram Moolenaarb8e22a02018-04-12 21:37:34 +0200381 if has("mac")
Bram Moolenaar98ad1e12019-01-30 21:51:27 +0100382 let found = (index(bsklist, '/private/tmp/*') >= 0)
383 call assert_true(found, '/private/tmp not in option bsk: ' . &bsk)
Bram Moolenaarb8e22a02018-04-12 21:37:34 +0200384 elseif has("unix")
Bram Moolenaar98ad1e12019-01-30 21:51:27 +0100385 let found = (index(bsklist, '/tmp/*') >= 0)
386 call assert_true(found, '/tmp not in option bsk: ' . &bsk)
Bram Moolenaarb8e22a02018-04-12 21:37:34 +0200387 endif
388
Bram Moolenaar98ad1e12019-01-30 21:51:27 +0100389 " If our test platform is Windows, the path(s) in option bsk will use
390 " backslash for the path separator and the components could be in short
391 " (8.3) format. As such, we need to replace the backslashes with forward
392 " slashes and convert the path components to long format. The expand()
393 " function will do this but it cannot handle comma-separated paths. This is
394 " why bsk was converted from a string into a list of strings above.
395 "
396 " One final complication is that the wildcard "/*" is at the end of each
397 " path and so expand() might return a list of matching files. To prevent
398 " this, we need to remove the wildcard before calling expand() and then
399 " append it afterwards.
400 if has('win32')
401 let item_nbr = 0
402 while item_nbr < len(bsklist)
403 let path_spec = bsklist[item_nbr]
404 let path_spec = strcharpart(path_spec, 0, strlen(path_spec)-2)
405 let path_spec = substitute(expand(path_spec), '\\', '/', 'g')
406 let bsklist[item_nbr] = path_spec . '/*'
407 let item_nbr += 1
408 endwhile
409 endif
410
411 " Option bsk will also include these environment variables if defined.
412 " If they're defined, verify they appear in the option value.
413 for var in ['$TMPDIR', '$TMP', '$TEMP']
Bram Moolenaarb8e22a02018-04-12 21:37:34 +0200414 if exists(var)
415 let varvalue = substitute(expand(var), '\\', '/', 'g')
Bram Moolenaarcbbd0f62019-01-30 22:36:18 +0100416 let varvalue = substitute(varvalue, '/$', '', '')
417 let varvalue .= '/*'
418 let found = (index(bsklist, varvalue) >= 0)
419 call assert_true(found, var . ' (' . varvalue . ') not in option bsk: ' . &bsk)
Bram Moolenaarb8e22a02018-04-12 21:37:34 +0200420 endif
421 endfor
422endfunc
Bram Moolenaar25782a72018-05-13 18:05:33 +0200423
424func Test_copy_winopt()
Bram Moolenaar7cb33a12018-08-23 22:20:35 +0200425 set hidden
Bram Moolenaar25782a72018-05-13 18:05:33 +0200426
Bram Moolenaar7cb33a12018-08-23 22:20:35 +0200427 " Test copy option from current buffer in window
428 split
429 enew
430 setlocal numberwidth=5
431 wincmd w
432 call assert_equal(4,&numberwidth)
433 bnext
434 call assert_equal(5,&numberwidth)
435 bw!
436 call assert_equal(4,&numberwidth)
Bram Moolenaar25782a72018-05-13 18:05:33 +0200437
Bram Moolenaar7cb33a12018-08-23 22:20:35 +0200438 " Test copy value from window that used to be display the buffer
439 split
440 enew
441 setlocal numberwidth=6
442 bnext
443 wincmd w
444 call assert_equal(4,&numberwidth)
445 bnext
446 call assert_equal(6,&numberwidth)
447 bw!
Bram Moolenaar25782a72018-05-13 18:05:33 +0200448
Bram Moolenaar7cb33a12018-08-23 22:20:35 +0200449 " Test that if buffer is current, don't use the stale cached value
450 " from the last time the buffer was displayed.
451 split
452 enew
453 setlocal numberwidth=7
454 bnext
455 bnext
456 setlocal numberwidth=8
457 wincmd w
458 call assert_equal(4,&numberwidth)
459 bnext
460 call assert_equal(8,&numberwidth)
461 bw!
Bram Moolenaar25782a72018-05-13 18:05:33 +0200462
Bram Moolenaar7cb33a12018-08-23 22:20:35 +0200463 " Test value is not copied if window already has seen the buffer
464 enew
465 split
466 setlocal numberwidth=9
467 bnext
468 setlocal numberwidth=10
469 wincmd w
470 call assert_equal(4,&numberwidth)
471 bnext
472 call assert_equal(4,&numberwidth)
473 bw!
474
475 set hidden&
Bram Moolenaar25782a72018-05-13 18:05:33 +0200476endfunc
Bram Moolenaarfc089602018-06-24 16:53:35 +0200477
478func Test_shortmess_F()
479 new
480 call assert_match('\[No Name\]', execute('file'))
481 set shortmess+=F
482 call assert_match('\[No Name\]', execute('file'))
483 call assert_match('^\s*$', execute('file foo'))
484 call assert_match('foo', execute('file'))
485 set shortmess-=F
486 call assert_match('bar', execute('file bar'))
487 call assert_match('bar', execute('file'))
488 set shortmess&
489 bwipe
490endfunc
Bram Moolenaar2f0f8712018-08-21 18:50:18 +0200491
492func Test_shortmess_F2()
493 e file1
494 e file2
495 call assert_match('file1', execute('bn', ''))
496 call assert_match('file2', execute('bn', ''))
497 set shortmess+=F
498 call assert_true(empty(execute('bn', '')))
Bram Moolenaareda65222019-05-16 20:29:44 +0200499 call assert_false(test_getvalue('need_fileinfo'))
Bram Moolenaar2f0f8712018-08-21 18:50:18 +0200500 call assert_true(empty(execute('bn', '')))
Bram Moolenaareda65222019-05-16 20:29:44 +0200501 call assert_false(test_getvalue('need_fileinfo'))
Bram Moolenaar2f0f8712018-08-21 18:50:18 +0200502 set hidden
503 call assert_true(empty(execute('bn', '')))
Bram Moolenaareda65222019-05-16 20:29:44 +0200504 call assert_false(test_getvalue('need_fileinfo'))
Bram Moolenaar2f0f8712018-08-21 18:50:18 +0200505 call assert_true(empty(execute('bn', '')))
Bram Moolenaareda65222019-05-16 20:29:44 +0200506 call assert_false(test_getvalue('need_fileinfo'))
Bram Moolenaar2f0f8712018-08-21 18:50:18 +0200507 set nohidden
508 call assert_true(empty(execute('bn', '')))
Bram Moolenaareda65222019-05-16 20:29:44 +0200509 call assert_false(test_getvalue('need_fileinfo'))
Bram Moolenaar2f0f8712018-08-21 18:50:18 +0200510 call assert_true(empty(execute('bn', '')))
Bram Moolenaareda65222019-05-16 20:29:44 +0200511 call assert_false(test_getvalue('need_fileinfo'))
Bram Moolenaar2f0f8712018-08-21 18:50:18 +0200512 set shortmess&
513 call assert_match('file1', execute('bn', ''))
514 call assert_match('file2', execute('bn', ''))
515 bwipe
516 bwipe
517endfunc
Bram Moolenaar375e3392019-01-31 18:26:10 +0100518
519func Test_local_scrolloff()
520 set so=5
521 set siso=7
522 split
523 call assert_equal(5, &so)
524 setlocal so=3
525 call assert_equal(3, &so)
526 wincmd w
527 call assert_equal(5, &so)
528 wincmd w
529 setlocal so<
530 call assert_equal(5, &so)
531 setlocal so=0
532 call assert_equal(0, &so)
533 setlocal so=-1
534 call assert_equal(5, &so)
535
536 call assert_equal(7, &siso)
537 setlocal siso=3
538 call assert_equal(3, &siso)
539 wincmd w
540 call assert_equal(7, &siso)
541 wincmd w
542 setlocal siso<
543 call assert_equal(7, &siso)
544 setlocal siso=0
545 call assert_equal(0, &siso)
546 setlocal siso=-1
547 call assert_equal(7, &siso)
548
549 close
550 set so&
551 set siso&
552endfunc
Bram Moolenaar449ac472019-04-03 21:42:35 +0200553
554func Test_writedelay()
555 if !has('reltime')
556 return
557 endif
558 new
559 call setline(1, 'empty')
560 redraw
561 set writedelay=10
562 let start = reltime()
563 call setline(1, repeat('x', 70))
564 redraw
565 let elapsed = reltimefloat(reltime(start))
566 set writedelay=0
567 " With 'writedelay' set should take at least 30 * 10 msec
568 call assert_inrange(30 * 0.01, 999.0, elapsed)
569
570 bwipe!
Bram Moolenaarb4e6a2d2019-04-03 21:53:33 +0200571endfunc
572
573func Test_visualbell()
Bram Moolenaar7a666272019-04-03 22:52:34 +0200574 set belloff=
Bram Moolenaarb4e6a2d2019-04-03 21:53:33 +0200575 set visualbell
576 call assert_beeps('normal 0h')
577 set novisualbell
Bram Moolenaar7a666272019-04-03 22:52:34 +0200578 set belloff=all
Bram Moolenaar449ac472019-04-03 21:42:35 +0200579endfunc