" Test for options
source shared.vim
source check.vim
source view_util.vim
func Test_whichwrap()
set whichwrap=b,s
call assert_equal('b,s', &whichwrap)
set whichwrap+=h,l
call assert_equal('b,s,h,l', &whichwrap)
set whichwrap+=h,l
call assert_equal('b,s,h,l', &whichwrap)
set whichwrap+=h,l
call assert_equal('b,s,h,l', &whichwrap)
set whichwrap=h,h
call assert_equal('h', &whichwrap)
set whichwrap=h,h,h
call assert_equal('h', &whichwrap)
" For compatibility with Vim 3.0 and before, number values are also
" supported for 'whichwrap'
set whichwrap=1
call assert_equal('b', &whichwrap)
set whichwrap=2
call assert_equal('s', &whichwrap)
set whichwrap=4
call assert_equal('h,l', &whichwrap)
set whichwrap=8
call assert_equal('<,>', &whichwrap)
set whichwrap=16
call assert_equal('[,]', &whichwrap)
set whichwrap=31
call assert_equal('b,s,h,l,<,>,[,]', &whichwrap)
set whichwrap&
endfunc
func Test_isfname()
" This used to cause Vim to access uninitialized memory.
set isfname=
call assert_equal("~X", expand("~X"))
set isfname&
endfunc
func Test_wildchar()
" Empty 'wildchar' used to access invalid memory.
call assert_fails('set wildchar=', 'E521:')
call assert_fails('set wildchar=abc', 'E521:')
set wildchar=<Esc>
let a=execute('set wildchar?')
call assert_equal("\n wildchar=<Esc>", a)
set wildchar=27
let a=execute('set wildchar?')
call assert_equal("\n wildchar=<Esc>", a)
set wildchar&
endfunc
func Test_wildoptions()
set wildoptions=
set wildoptions+=tagfile
set wildoptions+=tagfile
call assert_equal('tagfile', &wildoptions)
endfunc
func Test_options_command()
let caught = 'ok'
try
options
catch
let caught = v:throwpoint . "\n" . v:exception
endtry
call assert_equal('ok', caught)
" Check if the option-window is opened horizontally.
wincmd j
call assert_notequal('option-window', bufname(''))
wincmd k
call assert_equal('option-window', bufname(''))
" close option-window
close
" Open the option-window vertically.
vert options
" Check if the option-window is opened vertically.
wincmd l
call assert_notequal('option-window', bufname(''))
wincmd h
call assert_equal('option-window', bufname(''))
" close option-window
close
" Open the option-window at the top.
set splitbelow
topleft options
call assert_equal(1, winnr())
close
" Open the option-window at the bottom.
set nosplitbelow
botright options
call assert_equal(winnr('$'), winnr())
close
set splitbelow&
" Open the option-window in a new tab.
tab options
" Check if the option-window is opened in a tab.
normal gT
call assert_notequal('option-window', bufname(''))
normal gt
call assert_equal('option-window', bufname(''))
" close option-window
close
" Open the options window browse
if has('browse')
browse set
call assert_equal('option-window', bufname(''))
close
endif
endfunc
func Test_path_keep_commas()
" Test that changing 'path' keeps two commas.
set path=foo,,bar
set path-=bar
set path+=bar
call assert_equal('foo,,bar', &path)
set path&
endfunc
func Test_path_too_long()
exe 'set path=' .. repeat('x', 10000)
call assert_fails('find x', 'E854:')
set path&
endfunc
func Test_signcolumn()
CheckFeature signs
call assert_equal("auto", &signcolumn)
set signcolumn=yes
set signcolumn=no
call assert_fails('set signcolumn=nope')
endfunc
func Test_filetype_valid()
set ft=valid_name
call assert_equal("valid_name", &filetype)
set ft=valid-name
call assert_equal("valid-name", &filetype)
call assert_fails(":set ft=wrong;name", "E474:")
call assert_fails(":set ft=wrong\\\\name", "E474:")
call assert_fails(":set ft=wrong\\|name", "E474:")