mirror of
https://github.com/neovim/neovim.git
synced 2026-07-22 00:51:33 +00:00
vim-patch:9.0.1631: passing wrong variable type to option gives multiple errors (#24026)
Problem: Passing a wrong variable type to an option gives multiple errors.
Solution: Bail out early on failure. (closes vim/vim#12504)
4c7cb372c1
This commit is contained in:
@@ -242,7 +242,7 @@ func Test_let_no_type_checking()
|
||||
endfunc
|
||||
|
||||
func Test_let_termcap()
|
||||
throw 'skipped: Nvim does not support termcap option'
|
||||
throw 'Skipped: Nvim does not support termcap options'
|
||||
" Terminal code
|
||||
let old_t_te = &t_te
|
||||
let &t_te = "\<Esc>[yes;"
|
||||
@@ -257,25 +257,45 @@ func Test_let_termcap()
|
||||
let &t_k1 = old_t_k1
|
||||
endif
|
||||
|
||||
call assert_fails('let x = &t_xx', 'E113')
|
||||
call assert_fails('let x = &t_xx', 'E113:')
|
||||
let &t_xx = "yes"
|
||||
call assert_equal("yes", &t_xx)
|
||||
let &t_xx = ""
|
||||
call assert_fails('let x = &t_xx', 'E113')
|
||||
call assert_fails('let x = &t_xx', 'E113:')
|
||||
endfunc
|
||||
|
||||
func Test_let_option_error()
|
||||
let _w = &tw
|
||||
let &tw = 80
|
||||
call assert_fails('let &tw .= 1', 'E734')
|
||||
call assert_fails('let &tw .= 1', ['E734:', 'E734:'])
|
||||
call assert_fails('let &tw .= []', ['E734:', 'E734:'])
|
||||
call assert_fails('let &tw = []', ['E745:', 'E745:'])
|
||||
call assert_fails('let &tw += []', ['E745:', 'E745:'])
|
||||
call assert_equal(80, &tw)
|
||||
let &tw = _w
|
||||
|
||||
let _w = &autoread
|
||||
let &autoread = 1
|
||||
call assert_fails('let &autoread .= 1', ['E734:', 'E734:'])
|
||||
call assert_fails('let &autoread .= []', ['E734:', 'E734:'])
|
||||
call assert_fails('let &autoread = []', ['E745:', 'E745:'])
|
||||
call assert_fails('let &autoread += []', ['E745:', 'E745:'])
|
||||
call assert_equal(1, &autoread)
|
||||
let &autoread = _w
|
||||
|
||||
let _w = &fillchars
|
||||
let &fillchars = "vert:|"
|
||||
call assert_fails('let &fillchars += "diff:-"', 'E734')
|
||||
call assert_fails('let &fillchars += "diff:-"', ['E734:', 'E734:'])
|
||||
call assert_fails('let &fillchars += []', ['E734:', 'E734:'])
|
||||
call assert_fails('let &fillchars = []', ['E730:', 'E730:'])
|
||||
call assert_fails('let &fillchars .= []', ['E730:', 'E730:'])
|
||||
call assert_equal("vert:|", &fillchars)
|
||||
let &fillchars = _w
|
||||
|
||||
call assert_fails('let &nosuchoption = 1', ['E355:', 'E355:'])
|
||||
call assert_fails('let &nosuchoption = ""', ['E355:', 'E355:'])
|
||||
call assert_fails('let &nosuchoption = []', ['E355:', 'E355:'])
|
||||
call assert_fails('let &t_xx = []', ['E730:', 'E730:'])
|
||||
endfunc
|
||||
|
||||
" Errors with the :let statement
|
||||
|
||||
@@ -380,7 +380,7 @@ func Test_set_completion()
|
||||
call assert_equal('"set filetype=' .. getcompletion('a*', 'filetype')->join(), @:)
|
||||
endfunc
|
||||
|
||||
func Test_set_errors()
|
||||
func Test_set_option_errors()
|
||||
call assert_fails('set scroll=-1', 'E49:')
|
||||
call assert_fails('set backupcopy=', 'E474:')
|
||||
call assert_fails('set regexpengine=3', 'E474:')
|
||||
@@ -482,7 +482,7 @@ func Test_set_errors()
|
||||
if has('python') || has('python3')
|
||||
call assert_fails('set pyxversion=6', 'E474:')
|
||||
endif
|
||||
call assert_fails("let &tabstop='ab'", 'E521:')
|
||||
call assert_fails("let &tabstop='ab'", ['E521:', 'E521:'])
|
||||
call assert_fails('set spellcapcheck=%\\(', 'E54:')
|
||||
call assert_fails('set sessionoptions=curdir,sesdir', 'E474:')
|
||||
call assert_fails('set foldmarker={{{,', 'E474:')
|
||||
@@ -506,6 +506,12 @@ func Test_set_errors()
|
||||
" call assert_fails('set t_#-&', 'E522:')
|
||||
call assert_fails('let &formatoptions = "?"', 'E539:')
|
||||
call assert_fails('call setbufvar("", "&formatoptions", "?")', 'E539:')
|
||||
call assert_fails('call setwinvar(0, "&scrolloff", [])', ['E745:', 'E745:'])
|
||||
call assert_fails('call setwinvar(0, "&list", [])', ['E745:', 'E745:'])
|
||||
call assert_fails('call setwinvar(0, "&listchars", [])', ['E730:', 'E730:'])
|
||||
call assert_fails('call setwinvar(0, "&nosuchoption", 0)', ['E355:', 'E355:'])
|
||||
call assert_fails('call setwinvar(0, "&nosuchoption", "")', ['E355:', 'E355:'])
|
||||
call assert_fails('call setwinvar(0, "&nosuchoption", [])', ['E355:', 'E355:'])
|
||||
endfunc
|
||||
|
||||
func CheckWasSet(name)
|
||||
|
||||
@@ -6997,10 +6997,7 @@ func Test_compound_assignment_operators()
|
||||
call assert_equal(6, &scrolljump)
|
||||
let &scrolljump %= 5
|
||||
call assert_equal(1, &scrolljump)
|
||||
" A different error is shown due to a change in implementation of option
|
||||
" values.
|
||||
" call assert_fails('let &scrolljump .= "j"', 'E734:')
|
||||
call assert_fails('let &scrolljump .= "j"', 'E521:')
|
||||
call assert_fails('let &scrolljump .= "j"', ['E734:', 'E734:'])
|
||||
set scrolljump&vim
|
||||
|
||||
let &foldlevelstart = 2
|
||||
|
||||
Reference in New Issue
Block a user