forked from aniani/vim
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Problem: Vim9: inconsistent arguments for test functions.
Solution: When :def function and script have different arguments use a list
with two items instead of a separate function.
This commit is contained in:
@@ -100,36 +100,46 @@ def CheckDefAndScriptSuccess(lines: list<string>)
|
||||
CheckScriptSuccess(['vim9script'] + lines)
|
||||
enddef
|
||||
|
||||
" Check that a command fails with the same error when used in a :def function
|
||||
" and when used in Vim9 script.
|
||||
def CheckDefAndScriptFailure(lines: list<string>, error: string, lnum = -3)
|
||||
CheckDefFailure(lines, error, lnum)
|
||||
CheckScriptFailure(['vim9script'] + lines, error, lnum + 1)
|
||||
enddef
|
||||
|
||||
" As CheckDefAndScriptFailure() but with two different expected errors.
|
||||
def CheckDefAndScriptFailure2(
|
||||
lines: list<string>,
|
||||
errorDef: string,
|
||||
errorScript: string,
|
||||
lnum = -3)
|
||||
" Check that a command fails when used in a :def function and when used in
|
||||
" Vim9 script.
|
||||
" When "error" is a string, both with the same error.
|
||||
" When "error" is a list, the :def function fails with "error[0]" , the script
|
||||
" fails with "error[1]".
|
||||
def CheckDefAndScriptFailure(lines: list<string>, error: any, lnum = -3)
|
||||
var errorDef: string
|
||||
var errorScript: string
|
||||
if type(error) == v:t_string
|
||||
errorDef = error
|
||||
errorScript = error
|
||||
elseif type(error) == v:t_list && len(error) == 2
|
||||
errorDef = error[0]
|
||||
errorScript = error[1]
|
||||
else
|
||||
echoerr 'error argument must be a string or a list with two items'
|
||||
return
|
||||
endif
|
||||
CheckDefFailure(lines, errorDef, lnum)
|
||||
CheckScriptFailure(['vim9script'] + lines, errorScript, lnum + 1)
|
||||
enddef
|
||||
|
||||
" Check that a command fails with the same error when executed in a :def
|
||||
" function and when used in Vim9 script.
|
||||
def CheckDefExecAndScriptFailure(lines: list<string>, error: string, lnum = -3)
|
||||
CheckDefExecFailure(lines, error, lnum)
|
||||
CheckScriptFailure(['vim9script'] + lines, error, lnum + 1)
|
||||
enddef
|
||||
|
||||
" As CheckDefExecAndScriptFailure() but with two different expected errors.
|
||||
def CheckDefExecAndScriptFailure2(
|
||||
lines: list<string>,
|
||||
errorDef: string,
|
||||
errorScript: string,
|
||||
lnum = -3)
|
||||
" Check that a command fails when executed in a :def function and when used in
|
||||
" Vim9 script.
|
||||
" When "error" is a string, both with the same error.
|
||||
" When "error" is a list, the :def function fails with "error[0]" , the script
|
||||
" fails with "error[1]".
|
||||
def CheckDefExecAndScriptFailure(lines: list<string>, error: any, lnum = -3)
|
||||
var errorDef: string
|
||||
var errorScript: string
|
||||
if type(error) == v:t_string
|
||||
errorDef = error
|
||||
errorScript = error
|
||||
elseif type(error) == v:t_list && len(error) == 2
|
||||
errorDef = error[0]
|
||||
errorScript = error[1]
|
||||
else
|
||||
echoerr 'error argument must be a string or a list with two items'
|
||||
return
|
||||
endif
|
||||
CheckDefExecFailure(lines, errorDef, lnum)
|
||||
CheckScriptFailure(['vim9script'] + lines, errorScript, lnum + 1)
|
||||
enddef
|
||||
|
||||
Reference in New Issue
Block a user