0
0
mirror of https://github.com/vim/vim.git synced 2025-09-01 21:03:39 -04:00

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:
Bram Moolenaar 2021-12-19 18:33:23 +00:00
parent 700e6b1662
commit 86b3ab4fa0
13 changed files with 1007 additions and 995 deletions

View File

@ -40,7 +40,7 @@ func Test_execute_string()
if has('float')
call assert_fails('call execute(3.4)', 'E492:')
call assert_equal("\nx", execute("echo \"x\"", 3.4))
call CheckDefExecAndScriptFailure2(['execute("echo \"x\"", 3.4)'], 'E1013: Argument 2: type mismatch, expected string but got float', 'E1174:')
call CheckDefExecAndScriptFailure(['execute("echo \"x\"", 3.4)'], ['E1013: Argument 2: type mismatch, expected string but got float', 'E1174:'])
endif
endfunc

View File

@ -246,7 +246,7 @@ func Test_str2float()
call assert_equal('123456.7', string(str2float("123'456.7'89", 1)))
call assert_equal(1.2, str2float(1.2, 0))
call CheckDefAndScriptFailure2(['str2float(1.2)'], 'E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1')
call CheckDefAndScriptFailure(['str2float(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1'])
call assert_fails("call str2float([])", 'E730:')
call assert_fails("call str2float({})", 'E731:')
call assert_fails("call str2float(function('string'))", 'E729:')

View File

@ -174,7 +174,7 @@ func Test_strwidth()
if has('float')
call assert_equal(3, strwidth(1.2))
call CheckDefAndScriptFailure2(['echo strwidth(1.2)'], 'E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1')
call CheckDefAndScriptFailure(['echo strwidth(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1'])
endif
set ambiwidth&
@ -241,7 +241,7 @@ func Test_str2nr()
call assert_fails('call str2nr({->2})', 'E729:')
if has('float')
call assert_equal(1, str2nr(1.2))
call CheckDefAndScriptFailure2(['echo str2nr(1.2)'], 'E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1')
call CheckDefAndScriptFailure(['echo str2nr(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1'])
endif
call assert_fails('call str2nr(10, [])', 'E745:')
endfunc
@ -503,7 +503,7 @@ func Test_simplify()
call assert_fails('call simplify({})', 'E731:')
if has('float')
call assert_equal('1.2', simplify(1.2))
call CheckDefAndScriptFailure2(['echo simplify(1.2)'], 'E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1')
call CheckDefAndScriptFailure(['echo simplify(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1'])
endif
endfunc

View File

@ -5,7 +5,7 @@ source vim9.vim
func Test_glob2regpat_invalid()
if has('float')
call assert_equal('^1\.33$', glob2regpat(1.33))
call CheckDefAndScriptFailure2(['echo glob2regpat(1.2)'], 'E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1')
call CheckDefAndScriptFailure(['echo glob2regpat(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1'])
endif
call assert_fails('call glob2regpat("}")', 'E219:')
call assert_fails('call glob2regpat("{")', 'E220:')

View File

@ -1298,7 +1298,7 @@ func Test_listdict_index()
call CheckLegacyAndVim9Failure(['VAR d = {"k": 10}', 'echo d[1 : 2]'], 'E719:')
call assert_fails("let v = [4, 6][{-> 1}]", 'E729:')
call CheckDefAndScriptFailure2(['var v = [4, 6][() => 1]'], 'E1012', 'E703:')
call CheckDefAndScriptFailure(['var v = [4, 6][() => 1]'], ['E1012', 'E703:'])
call CheckLegacyAndVim9Failure(['VAR v = range(5)[2 : []]'], ['E730:', 'E1012:', 'E730:'])

View File

@ -280,12 +280,12 @@ def Test_assign_concat()
var s = '-'
s ..= [1, 2]
END
CheckDefAndScriptFailure2(lines, 'E1105: Cannot convert list to string', 'E734: Wrong variable type for .=', 2)
CheckDefAndScriptFailure(lines, ['E1105: Cannot convert list to string', 'E734: Wrong variable type for .='], 2)
lines =<< trim END
var s = '-'
s ..= {a: 2}
END
CheckDefAndScriptFailure2(lines, 'E1105: Cannot convert dict to string', 'E734: Wrong variable type for .=', 2)
CheckDefAndScriptFailure(lines, ['E1105: Cannot convert dict to string', 'E734: Wrong variable type for .='], 2)
enddef
def Test_assign_register()
@ -493,7 +493,7 @@ def Test_assign_linebreak()
+ 4
+ 5
END
CheckDefExecAndScriptFailure2(lines, 'E1148:', 'E1203:', 2)
CheckDefExecAndScriptFailure(lines, ['E1148:', 'E1203:'], 2)
enddef
def Test_assign_index()
@ -783,21 +783,21 @@ def Test_list_declaration()
var lines =<< trim END
var [v1, v2] = [1]
END
CheckDefExecAndScriptFailure2(lines, 'E1093: Expected 2 items but got 1', 'E688:')
CheckDefExecAndScriptFailure(lines, ['E1093: Expected 2 items but got 1', 'E688:'])
lines =<< trim END
var testlist = [1]
var [v1, v2] = testlist
END
CheckDefExecAndScriptFailure2(lines, 'E1093: Expected 2 items but got 1', 'E688:')
CheckDefExecAndScriptFailure(lines, ['E1093: Expected 2 items but got 1', 'E688:'])
lines =<< trim END
var [v1, v2] = [1, 2, 3]
END
CheckDefExecAndScriptFailure2(lines, 'E1093: Expected 2 items but got 3', 'E687:')
CheckDefExecAndScriptFailure(lines, ['E1093: Expected 2 items but got 3', 'E687:'])
lines =<< trim END
var testlist = [1, 2, 3]
var [v1, v2] = testlist
END
CheckDefExecAndScriptFailure2(lines, 'E1093: Expected 2 items but got 3', 'E687:')
CheckDefExecAndScriptFailure(lines, ['E1093: Expected 2 items but got 3', 'E687:'])
var [vnr, vstr] = [123, 'text']
vnr += 3
@ -819,12 +819,12 @@ def Test_list_declaration()
lines =<< trim END
var [vnr2: number, vstr2: number] = [123, 'text']
END
CheckDefExecAndScriptFailure2(lines, 'E1163: Variable 2: type mismatch, expected number but got string', 'E1012: Type mismatch; expected number but got string')
CheckDefExecAndScriptFailure(lines, ['E1163: Variable 2: type mismatch, expected number but got string', 'E1012: Type mismatch; expected number but got string'])
lines =<< trim END
var testlist = [234, 'text']
var [vnr2: number, vstr2: number] = testlist
END
CheckDefExecAndScriptFailure2(lines, 'E1163: Variable 2: type mismatch, expected number but got string', 'E1012: Type mismatch; expected number but got string')
CheckDefExecAndScriptFailure(lines, ['E1163: Variable 2: type mismatch, expected number but got string', 'E1012: Type mismatch; expected number but got string'])
enddef
def PartFuncBool(b: bool): string
@ -989,7 +989,7 @@ def Test_assignment_dict()
var n: any
n.key = 5
END
CheckDefExecAndScriptFailure2(lines, 'E1148:', 'E1203: Dot can only be used on a dictionary: n.key = 5', 2)
CheckDefExecAndScriptFailure(lines, ['E1148:', 'E1203: Dot can only be used on a dictionary: n.key = 5'], 2)
enddef
def Test_assignment_local()
@ -1457,13 +1457,13 @@ def Test_assign_with_op_fails()
var s = 'abc'
s[1] += 'x'
END
CheckDefAndScriptFailure2(lines, 'E1141:', 'E689:', 2)
CheckDefAndScriptFailure(lines, ['E1141:', 'E689:'], 2)
lines =<< trim END
var s = 'abc'
s[1] ..= 'x'
END
CheckDefAndScriptFailure2(lines, 'E1141:', 'E689:', 2)
CheckDefAndScriptFailure(lines, ['E1141:', 'E689:'], 2)
lines =<< trim END
var dd: dict<dict<list<any>>>

File diff suppressed because it is too large Load Diff

View File

@ -1600,7 +1600,7 @@ def Test_var_not_cmd()
var lines =<< trim END
g:notexist:cmd
END
CheckDefAndScriptFailure2(lines, 'E488: Trailing characters: :cmd', 'E121: Undefined variable: g:notexist', 1)
CheckDefAndScriptFailure(lines, ['E488: Trailing characters: :cmd', 'E121: Undefined variable: g:notexist'], 1)
lines =<< trim END
g-pat-cmd
@ -1609,12 +1609,12 @@ def Test_var_not_cmd()
lines =<< trim END
g.pat.cmd
END
CheckDefAndScriptFailure2(lines, 'E1001: Variable not found: g', 'E121: Undefined variable: g', 1)
CheckDefAndScriptFailure(lines, ['E1001: Variable not found: g', 'E121: Undefined variable: g'], 1)
lines =<< trim END
s:notexist:repl
END
CheckDefAndScriptFailure2(lines, 'E488: Trailing characters: :repl', 'E121: Undefined variable: s:notexist', 1)
CheckDefAndScriptFailure(lines, ['E488: Trailing characters: :repl', 'E121: Undefined variable: s:notexist'], 1)
lines =<< trim END
s-pat-repl
@ -1623,7 +1623,7 @@ def Test_var_not_cmd()
lines =<< trim END
s.pat.repl
END
CheckDefAndScriptFailure2(lines, 'E1001: Variable not found: s', 'E121: Undefined variable: s', 1)
CheckDefAndScriptFailure(lines, ['E1001: Variable not found: s', 'E121: Undefined variable: s'], 1)
lines =<< trim END
w:notexist->len()

View File

@ -200,8 +200,8 @@ func Test_expr1_trinary_fails()
call CheckDefExecFailure(["var x = false ? 'one' : "], 'E1097:', 3)
call CheckScriptFailure(['vim9script', "var x = false ? 'one' : "], 'E15:', 2)
call CheckDefExecAndScriptFailure2(["var x = true ? xxx : 'foo'"], 'E1001:', 'E121:', 1)
call CheckDefExecAndScriptFailure2(["var x = false ? 'foo' : xxx"], 'E1001:', 'E121:', 1)
call CheckDefExecAndScriptFailure(["var x = true ? xxx : 'foo'"], ['E1001:', 'E121:'], 1)
call CheckDefExecAndScriptFailure(["var x = false ? 'foo' : xxx"], ['E1001:', 'E121:'], 1)
if has('float')
call CheckDefAndScriptFailure(["var x = 0.1 ? 'one' : 'two'"], 'E805:', 1)
@ -382,17 +382,17 @@ def Test_expr2_fails()
# script does not fail, the second expression is skipped
call CheckDefFailure(["var x = 1 || xxx"], 'E1001:', 1)
call CheckDefAndScriptFailure2(["var x = [] || false"], 'E1012:', 'E745:', 1)
call CheckDefAndScriptFailure(["var x = [] || false"], ['E1012:', 'E745:'], 1)
call CheckDefAndScriptFailure2(["if 'yes' || 0", 'echo 0', 'endif'], 'E1012: Type mismatch; expected bool but got string', 'E1135: Using a String as a Bool', 1)
call CheckDefAndScriptFailure(["if 'yes' || 0", 'echo 0', 'endif'], ['E1012: Type mismatch; expected bool but got string', 'E1135: Using a String as a Bool'], 1)
call CheckDefAndScriptFailure2(["var x = 3 || false"], 'E1012:', 'E1023:', 1)
call CheckDefAndScriptFailure2(["var x = false || 3"], 'E1012:', 'E1023:', 1)
call CheckDefAndScriptFailure(["var x = 3 || false"], ['E1012:', 'E1023:'], 1)
call CheckDefAndScriptFailure(["var x = false || 3"], ['E1012:', 'E1023:'], 1)
call CheckDefAndScriptFailure(["if 3"], 'E1023:', 1)
call CheckDefExecAndScriptFailure(['var x = 3', 'if x', 'endif'], 'E1023:', 2)
call CheckDefAndScriptFailure2(["var x = [] || false"], 'E1012: Type mismatch; expected bool but got list<unknown>', 'E745:', 1)
call CheckDefAndScriptFailure(["var x = [] || false"], ['E1012: Type mismatch; expected bool but got list<unknown>', 'E745:'], 1)
var lines =<< trim END
vim9script
@ -516,7 +516,7 @@ def Test_expr3_fails()
CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''&&'' at "&&0"', 2)
g:vals = []
CheckDefAndScriptFailure2(["if 'yes' && 0", 'echo 0', 'endif'], 'E1012: Type mismatch; expected bool but got string', 'E1135: Using a String as a Bool', 1)
CheckDefAndScriptFailure(["if 'yes' && 0", 'echo 0', 'endif'], ['E1012: Type mismatch; expected bool but got string', 'E1135: Using a String as a Bool'], 1)
CheckDefExecAndScriptFailure(['assert_equal(false, Record(1) && Record(4) && Record(0))'], 'E1023: Using a Number as a Bool: 4', 1)
@ -525,21 +525,21 @@ def Test_expr3_fails()
&& true
endif
END
CheckDefAndScriptFailure2(lines, 'E1012:', 'E1023:', 1)
CheckDefAndScriptFailure(lines, ['E1012:', 'E1023:'], 1)
lines =<< trim END
if true
&& 3
endif
END
CheckDefAndScriptFailure2(lines, 'E1012:', 'E1023:', 2)
CheckDefAndScriptFailure(lines, ['E1012:', 'E1023:'], 2)
lines =<< trim END
if 'yes'
&& true
endif
END
CheckDefAndScriptFailure2(lines, 'E1012:', 'E1135: Using a String as a Bool', 1)
CheckDefAndScriptFailure(lines, ['E1012:', 'E1135: Using a String as a Bool'], 1)
enddef
" global variables to use for tests with the "any" type
@ -665,16 +665,16 @@ def Test_expr4_equal()
END
CheckDefAndScriptSuccess(lines)
CheckDefAndScriptFailure2(["var x = 'a' == xxx"], 'E1001:', 'E121:', 1)
CheckDefAndScriptFailure(["var x = 'a' == xxx"], ['E1001:', 'E121:'], 1)
CheckDefFailure(["var x = 'a' == "], 'E1097:', 3)
CheckScriptFailure(['vim9script', "var x = 'a' == "], 'E15:', 2)
CheckDefExecAndScriptFailure2(['var items: any', 'eval 1 + 1', 'eval 2 + 2', 'if items == []', 'endif'], 'E691:', 'E1072:', 4)
CheckDefExecAndScriptFailure(['var items: any', 'eval 1 + 1', 'eval 2 + 2', 'if items == []', 'endif'], ['E691:', 'E1072:'], 4)
CheckDefExecAndScriptFailure(['var x: any = "a"', 'echo x == true'], 'E1072: Cannot compare string with bool', 2)
CheckDefExecAndScriptFailure(["var x: any = true", 'echo x == ""'], 'E1072: Cannot compare bool with string', 2)
CheckDefExecAndScriptFailure2(["var x: any = 99", 'echo x == true'], 'E1138', 'E1072:', 2)
CheckDefExecAndScriptFailure2(["var x: any = 'a'", 'echo x == 99'], 'E1030:', 'E1072:', 2)
CheckDefExecAndScriptFailure(["var x: any = 99", 'echo x == true'], ['E1138', 'E1072:'], 2)
CheckDefExecAndScriptFailure(["var x: any = 'a'", 'echo x == 99'], ['E1030:', 'E1072:'], 2)
enddef
def Test_expr4_wrong_type()
@ -685,9 +685,9 @@ def Test_expr4_wrong_type()
'echo a ' .. op .. ' b'], 'E1072:', 3)
endfor
for op in ['>', '>=', '<', '<=']
CheckDefExecAndScriptFailure2([
CheckDefExecAndScriptFailure([
"var n: any = 2",
'echo n ' .. op .. ' "3"'], 'E1030:', 'E1072:', 2)
'echo n ' .. op .. ' "3"'], ['E1030:', 'E1072:'], 2)
endfor
for op in ['=~', '!~']
CheckDefExecAndScriptFailure([
@ -1247,17 +1247,17 @@ def Test_expr5_vim9script()
lines =<< trim END
echo {} - 22
END
CheckDefAndScriptFailure2(lines, 'E1036:', 'E728:', 1)
CheckDefAndScriptFailure(lines, ['E1036:', 'E728:'], 1)
lines =<< trim END
echo [] - 33
END
CheckDefAndScriptFailure2(lines, 'E1036:', 'E745:', 1)
CheckDefAndScriptFailure(lines, ['E1036:', 'E745:'], 1)
lines =<< trim END
echo 0z1234 - 44
END
CheckDefAndScriptFailure2(lines, 'E1036', 'E974:', 1)
CheckDefAndScriptFailure(lines, ['E1036', 'E974:'], 1)
lines =<< trim END
echo 'abc' is? 'abc'
@ -1315,27 +1315,27 @@ def Test_expr5_vim9script()
lines =<< trim END
echo 'a' .. [1]
END
CheckDefAndScriptFailure2(lines, 'E1105:', 'E730:', 1)
CheckDefAndScriptFailure(lines, ['E1105:', 'E730:'], 1)
lines =<< trim END
echo 'a' .. {a: 1}
END
CheckDefAndScriptFailure2(lines, 'E1105:', 'E731:', 1)
CheckDefAndScriptFailure(lines, ['E1105:', 'E731:'], 1)
lines =<< trim END
echo 'a' .. test_void()
END
CheckDefAndScriptFailure2(lines, 'E1105:', 'E908:', 1)
CheckDefAndScriptFailure(lines, ['E1105:', 'E908:'], 1)
lines =<< trim END
echo 'a' .. 0z33
END
CheckDefAndScriptFailure2(lines, 'E1105:', 'E976:', 1)
CheckDefAndScriptFailure(lines, ['E1105:', 'E976:'], 1)
lines =<< trim END
echo 'a' .. function('len')
END
CheckDefAndScriptFailure2(lines, 'E1105:', 'E729:', 1)
CheckDefAndScriptFailure(lines, ['E1105:', 'E729:'], 1)
lines =<< trim END
new
@ -1361,11 +1361,11 @@ def Test_expr5_vim9script_channel()
var lines =<< trim END
echo 'a' .. test_null_job()
END
CheckDefAndScriptFailure2(lines, 'E1105:', 'E908:', 1)
CheckDefAndScriptFailure(lines, ['E1105:', 'E908:'], 1)
lines =<< trim END
echo 'a' .. test_null_channel()
END
CheckDefAndScriptFailure2(lines, 'E1105:', 'E908:', 1)
CheckDefAndScriptFailure(lines, ['E1105:', 'E908:'], 1)
endif
enddef
@ -1413,33 +1413,33 @@ func Test_expr5_fails()
call CheckDefAndScriptFailure(["var x = '1' ..'2'"], msg, 1)
call CheckDefAndScriptFailure(["var x = '1'.. '2'"], msg, 1)
call CheckDefAndScriptFailure2(["var x = 0z1122 + 33"], 'E1051:', 'E974:', 1)
call CheckDefAndScriptFailure2(["var x = 0z1122 + [3]"], 'E1051:', 'E974:', 1)
call CheckDefAndScriptFailure2(["var x = 0z1122 + 'asd'"], 'E1051:', 'E974:', 1)
call CheckDefAndScriptFailure2(["var x = 33 + 0z1122"], 'E1051:', 'E974:', 1)
call CheckDefAndScriptFailure2(["var x = [3] + 0z1122"], 'E1051:', 'E745:', 1)
call CheckDefAndScriptFailure2(["var x = 'asdf' + 0z1122"], 'E1051:', 'E1030:', 1)
call CheckDefAndScriptFailure2(["var x = 6 + xxx"], 'E1001:', 'E121:', 1)
call CheckDefAndScriptFailure(["var x = 0z1122 + 33"], ['E1051:', 'E974:'], 1)
call CheckDefAndScriptFailure(["var x = 0z1122 + [3]"], ['E1051:', 'E974:'], 1)
call CheckDefAndScriptFailure(["var x = 0z1122 + 'asd'"], ['E1051:', 'E974:'], 1)
call CheckDefAndScriptFailure(["var x = 33 + 0z1122"], ['E1051:', 'E974:'], 1)
call CheckDefAndScriptFailure(["var x = [3] + 0z1122"], ['E1051:', 'E745:'], 1)
call CheckDefAndScriptFailure(["var x = 'asdf' + 0z1122"], ['E1051:', 'E1030:'], 1)
call CheckDefAndScriptFailure(["var x = 6 + xxx"], ['E1001:', 'E121:'], 1)
call CheckDefAndScriptFailure2(["var x = 'a' .. [1]"], 'E1105:', 'E730:', 1)
call CheckDefAndScriptFailure2(["var x = 'a' .. {a: 1}"], 'E1105:', 'E731:', 1)
call CheckDefAndScriptFailure2(["var x = 'a' .. test_void()"], 'E1105:', 'E908:', 1)
call CheckDefAndScriptFailure2(["var x = 'a' .. 0z32"], 'E1105:', 'E976:', 1)
call CheckDefAndScriptFailure2(["var x = 'a' .. function('len')"], 'E1105:', 'E729:', 1)
call CheckDefAndScriptFailure2(["var x = 'a' .. function('len', ['a'])"], 'E1105:', 'E729:', 1)
call CheckDefAndScriptFailure(["var x = 'a' .. [1]"], ['E1105:', 'E730:'], 1)
call CheckDefAndScriptFailure(["var x = 'a' .. {a: 1}"], ['E1105:', 'E731:'], 1)
call CheckDefAndScriptFailure(["var x = 'a' .. test_void()"], ['E1105:', 'E908:'], 1)
call CheckDefAndScriptFailure(["var x = 'a' .. 0z32"], ['E1105:', 'E976:'], 1)
call CheckDefAndScriptFailure(["var x = 'a' .. function('len')"], ['E1105:', 'E729:'], 1)
call CheckDefAndScriptFailure(["var x = 'a' .. function('len', ['a'])"], ['E1105:', 'E729:'], 1)
call CheckDefAndScriptFailure2(['var x = 1 + v:none'], 'E1051:', 'E611:', 1)
call CheckDefAndScriptFailure2(['var x = 1 + v:null'], 'E1051:', 'E611:', 1)
call CheckDefAndScriptFailure2(['var x = 1 + v:true'], 'E1051:', 'E1138:', 1)
call CheckDefAndScriptFailure2(['var x = 1 + v:false'], 'E1051:', 'E1138:', 1)
call CheckDefAndScriptFailure2(['var x = 1 + true'], 'E1051:', 'E1138:', 1)
call CheckDefAndScriptFailure2(['var x = 1 + false'], 'E1051:', 'E1138:', 1)
call CheckDefAndScriptFailure(['var x = 1 + v:none'], ['E1051:', 'E611:'], 1)
call CheckDefAndScriptFailure(['var x = 1 + v:null'], ['E1051:', 'E611:'], 1)
call CheckDefAndScriptFailure(['var x = 1 + v:true'], ['E1051:', 'E1138:'], 1)
call CheckDefAndScriptFailure(['var x = 1 + v:false'], ['E1051:', 'E1138:'], 1)
call CheckDefAndScriptFailure(['var x = 1 + true'], ['E1051:', 'E1138:'], 1)
call CheckDefAndScriptFailure(['var x = 1 + false'], ['E1051:', 'E1138:'], 1)
endfunc
func Test_expr5_fails_channel()
CheckFeature channel
call CheckDefAndScriptFailure2(["var x = 'a' .. test_null_job()"], 'E1105:', 'E908:', 1)
call CheckDefAndScriptFailure2(["var x = 'a' .. test_null_channel()"], 'E1105:', 'E908:', 1)
call CheckDefAndScriptFailure(["var x = 'a' .. test_null_job()"], ['E1105:', 'E908:'], 1)
call CheckDefAndScriptFailure(["var x = 'a' .. test_null_channel()"], ['E1105:', 'E908:'], 1)
endfunc
def Test_expr5_list_add()
@ -1504,7 +1504,7 @@ def Test_expr6()
END
CheckDefAndScriptSuccess(lines)
CheckDefAndScriptFailure2(["var x = 6 * xxx"], 'E1001:', 'E121:', 1)
CheckDefAndScriptFailure(["var x = 6 * xxx"], ['E1001:', 'E121:'], 1)
CheckDefFailure(["var d = 6 * "], 'E1097:', 3)
CheckScriptFailure(['vim9script', "var d = 6 * "], 'E15:', 2)
@ -1625,25 +1625,25 @@ func Test_expr6_fails()
call CheckDefAndScriptFailure(["var x = 1 %2"], msg, 1)
call CheckDefAndScriptFailure(["var x = 1% 2"], msg, 1)
call CheckDefAndScriptFailure2(["var x = '1' * '2'"], 'E1036:', 'E1030:', 1)
call CheckDefAndScriptFailure2(["var x = '1' / '2'"], 'E1036:', 'E1030:', 1)
call CheckDefAndScriptFailure2(["var x = '1' % '2'"], 'E1035:', 'E1030:', 1)
call CheckDefAndScriptFailure(["var x = '1' * '2'"], ['E1036:', 'E1030:'], 1)
call CheckDefAndScriptFailure(["var x = '1' / '2'"], ['E1036:', 'E1030:'], 1)
call CheckDefAndScriptFailure(["var x = '1' % '2'"], ['E1035:', 'E1030:'], 1)
call CheckDefAndScriptFailure2(["var x = 0z01 * 0z12"], 'E1036:', 'E974:', 1)
call CheckDefAndScriptFailure2(["var x = 0z01 / 0z12"], 'E1036:', 'E974:', 1)
call CheckDefAndScriptFailure2(["var x = 0z01 % 0z12"], 'E1035:', 'E974:', 1)
call CheckDefAndScriptFailure(["var x = 0z01 * 0z12"], ['E1036:', 'E974:'], 1)
call CheckDefAndScriptFailure(["var x = 0z01 / 0z12"], ['E1036:', 'E974:'], 1)
call CheckDefAndScriptFailure(["var x = 0z01 % 0z12"], ['E1035:', 'E974:'], 1)
call CheckDefAndScriptFailure2(["var x = [1] * [2]"], 'E1036:', 'E745:', 1)
call CheckDefAndScriptFailure2(["var x = [1] / [2]"], 'E1036:', 'E745:', 1)
call CheckDefAndScriptFailure2(["var x = [1] % [2]"], 'E1035:', 'E745:', 1)
call CheckDefAndScriptFailure(["var x = [1] * [2]"], ['E1036:', 'E745:'], 1)
call CheckDefAndScriptFailure(["var x = [1] / [2]"], ['E1036:', 'E745:'], 1)
call CheckDefAndScriptFailure(["var x = [1] % [2]"], ['E1035:', 'E745:'], 1)
call CheckDefAndScriptFailure2(["var x = {one: 1} * {two: 2}"], 'E1036:', 'E728:', 1)
call CheckDefAndScriptFailure2(["var x = {one: 1} / {two: 2}"], 'E1036:', 'E728:', 1)
call CheckDefAndScriptFailure2(["var x = {one: 1} % {two: 2}"], 'E1035:', 'E728:', 1)
call CheckDefAndScriptFailure(["var x = {one: 1} * {two: 2}"], ['E1036:', 'E728:'], 1)
call CheckDefAndScriptFailure(["var x = {one: 1} / {two: 2}"], ['E1036:', 'E728:'], 1)
call CheckDefAndScriptFailure(["var x = {one: 1} % {two: 2}"], ['E1035:', 'E728:'], 1)
call CheckDefAndScriptFailure2(["var x = 0xff[1]"], 'E1107:', 'E1062:', 1)
call CheckDefAndScriptFailure(["var x = 0xff[1]"], ['E1107:', 'E1062:'], 1)
if has('float')
call CheckDefAndScriptFailure2(["var x = 0.7[1]"], 'E1107:', 'E806:', 1)
call CheckDefAndScriptFailure(["var x = 0.7[1]"], ['E1107:', 'E806:'], 1)
endif
for op in ['*', '/', '%']
@ -1655,7 +1655,7 @@ endfunc
func Test_expr6_float_fails()
CheckFeature float
call CheckDefAndScriptFailure2(["var x = 1.0 % 2"], 'E1035:', 'E804:', 1)
call CheckDefAndScriptFailure(["var x = 1.0 % 2"], ['E1035:', 'E804:'], 1)
endfunc
" define here to use old style parsing
@ -1871,17 +1871,17 @@ def Test_expr7_list()
g:rangelist = range(3)
CheckDefExecAndScriptFailure(["var x: list<string> = g:rangelist"], 'E1012: Type mismatch; expected list<string> but got list<number>', 1)
CheckDefAndScriptFailure2(["var x = 1234[3]"], 'E1107:', 'E1062:', 1)
CheckDefAndScriptFailure(["var x = 1234[3]"], ['E1107:', 'E1062:'], 1)
CheckDefExecAndScriptFailure(["var x = g:anint[3]"], 'E1062:', 1)
CheckDefAndScriptFailure2(["var x = g:list_mixed[xxx]"], 'E1001:', 'E121:', 1)
CheckDefAndScriptFailure(["var x = g:list_mixed[xxx]"], ['E1001:', 'E121:'], 1)
CheckDefAndScriptFailure(["var x = [1,2,3]"], 'E1069:', 1)
CheckDefAndScriptFailure(["var x = [1 ,2, 3]"], 'E1068:', 1)
CheckDefExecAndScriptFailure(["echo 1", "var x = [][0]", "echo 3"], 'E684:', 2)
CheckDefExecAndScriptFailure2(["var x = g:list_mixed['xx']"], 'E1012:', 'E1030:', 1)
CheckDefExecAndScriptFailure(["var x = g:list_mixed['xx']"], ['E1012:', 'E1030:'], 1)
CheckDefFailure(["var x = g:list_mixed["], 'E1097:', 3)
CheckScriptFailure(['vim9script', "var x = g:list_mixed["], 'E15:', 2)
CheckDefFailure(["var x = g:list_mixed[0"], 'E1097:', 3)
@ -2057,7 +2057,7 @@ def Test_expr7_lambda()
CheckDefAndScriptFailure(["var Ref = (a)=>a + 1"], 'E1004:')
CheckDefAndScriptFailure(["var Ref = (a)=> a + 1"], 'E1004: White space required before and after ''=>'' at "=> a + 1"')
CheckDefAndScriptFailure(["var Ref = (a) =>a + 1"], 'E1004:')
CheckDefAndScriptFailure2(["var Ref = (a) =< a + 1"], 'E1001:', 'E121:')
CheckDefAndScriptFailure(["var Ref = (a) =< a + 1"], ['E1001:', 'E121:'])
CheckDefAndScriptFailure(["var Ref = (a: int) => a + 1"], 'E1010:')
CheckDefAndScriptFailure(["var Ref = (a): int => a + 1"], 'E1010:')
@ -2069,7 +2069,7 @@ def Test_expr7_lambda()
CheckDefExecFailure(["var s = 'asdf'->((a) => a)('x')"], 'E118:')
CheckDefExecFailure(["var s = 'asdf'->((a) => a)('x', 'y')"], 'E118:')
CheckDefAndScriptFailure2(["echo 'asdf'->((a) => a)(x)"], 'E1001:', 'E121:', 1)
CheckDefAndScriptFailure(["echo 'asdf'->((a) => a)(x)"], ['E1001:', 'E121:'], 1)
CheckDefAndScriptSuccess(['var Fx = (a) => ({k1: 0,', ' k2: 1})'])
CheckDefAndScriptFailure(['var Fx = (a) => ({k1: 0', ' k2: 1})'], 'E722:', 2)
@ -2235,7 +2235,7 @@ def Test_expr7_new_lambda()
CheckDefAndScriptFailure(["filter([1, 2], (k,v) => 1)"], 'E1069:', 1)
# error is in first line of the lambda
CheckDefAndScriptFailure2(["var L = (a) -> a + b"], 'E1001:', 'E121:', 1)
CheckDefAndScriptFailure(["var L = (a) -> a + b"], ['E1001:', 'E121:'], 1)
assert_equal('xxxyyy', 'xxx'->((a, b) => a .. b)('yyy'))
@ -2400,9 +2400,9 @@ def Test_expr7_dict()
CheckDefAndScriptFailure(["var x = {xxx: 1", "var y = 2"], 'E722:', 2)
CheckDefFailure(["var x = {xxx: 1,"], 'E723:', 2)
CheckScriptFailure(['vim9script', "var x = {xxx: 1,"], 'E723:', 2)
CheckDefAndScriptFailure2(["var x = {['a']: xxx}"], 'E1001:', 'E121:', 1)
CheckDefAndScriptFailure(["var x = {['a']: xxx}"], ['E1001:', 'E121:'], 1)
CheckDefAndScriptFailure(["var x = {a: 1, a: 2}"], 'E721:', 1)
CheckDefExecAndScriptFailure2(["var x = g:anint.member"], 'E715:', 'E488:', 1)
CheckDefExecAndScriptFailure(["var x = g:anint.member"], ['E715:', 'E488:'], 1)
CheckDefExecAndScriptFailure(["var x = g:dict_empty.member"], 'E716:', 1)
CheckDefExecAndScriptFailure(['var x: dict<number> = {a: 234, b: "1"}'], 'E1012:', 1)
@ -2411,7 +2411,7 @@ def Test_expr7_dict()
CheckDefExecAndScriptFailure(['var x: dict<string> = {a: "x", b: 134}'], 'E1012:', 1)
# invalid types for the key
CheckDefAndScriptFailure2(["var x = {[[1, 2]]: 0}"], 'E1105:', 'E730:', 1)
CheckDefAndScriptFailure(["var x = {[[1, 2]]: 0}"], ['E1105:', 'E730:'], 1)
CheckDefFailure(['var x = ({'], 'E723:', 2)
CheckScriptFailure(['vim9script', 'var x = ({'], 'E723:', 2)
@ -2615,7 +2615,7 @@ def Test_expr_member()
END
CheckDefAndScriptSuccess(lines)
CheckDefAndScriptFailure2(["var x = g:dict_one.#$!"], 'E1002:', 'E15:', 1)
CheckDefAndScriptFailure(["var x = g:dict_one.#$!"], ['E1002:', 'E15:'], 1)
CheckDefExecAndScriptFailure(["var d: dict<any>", "echo d['a']"], 'E716:', 2)
CheckDefExecAndScriptFailure(["var d: dict<number>", "d = g:list_empty"], 'E1012: Type mismatch; expected dict<number> but got list<unknown>', 2)
enddef
@ -2809,7 +2809,7 @@ def Test_expr7_environment()
END
CheckDefAndScriptSuccess(lines)
CheckDefAndScriptFailure2(["var x = $$$"], 'E1002:', 'E15:', 1)
CheckDefAndScriptFailure(["var x = $$$"], ['E1002:', 'E15:'], 1)
enddef
def Test_expr7_register()
@ -2834,7 +2834,7 @@ def Test_expr7_register()
END
CheckDefAndScriptSuccess(lines)
CheckDefAndScriptFailure2(["@. = 'yes'"], 'E354:', 'E488:', 1)
CheckDefAndScriptFailure(["@. = 'yes'"], ['E354:', 'E488:'], 1)
enddef
" This is slow when run under valgrind.
@ -3033,10 +3033,10 @@ def Test_expr7_call()
->s:Echo4Arg())
CheckDefAndScriptFailure(["var x = 'yes'->Echo"], 'E107:', 1)
CheckDefAndScriptFailure2([
CheckDefAndScriptFailure([
"var x = substitute ('x', 'x', 'x', 'x')"
], 'E1001:', 'E121:', 1)
CheckDefAndScriptFailure2(["var Ref = function('len' [1, 2])"], 'E1123:', 'E116:', 1)
], ['E1001:', 'E121:'], 1)
CheckDefAndScriptFailure(["var Ref = function('len' [1, 2])"], ['E1123:', 'E116:'], 1)
var auto_lines =<< trim END
def g:some#func(): string
@ -3172,8 +3172,8 @@ func Test_expr7_fails()
call CheckDefAndScriptFailure(["var x = -'xx'"], "E1030:", 1)
call CheckDefAndScriptFailure(["var x = +'xx'"], "E1030:", 1)
call CheckDefAndScriptFailure(["var x = -0z12"], "E974:", 1)
call CheckDefExecAndScriptFailure2(["var x = -[8]"], "E1012:", 'E745:', 1)
call CheckDefExecAndScriptFailure2(["var x = -{a: 1}"], "E1012:", 'E728:', 1)
call CheckDefExecAndScriptFailure(["var x = -[8]"], ["E1012:", 'E745:'], 1)
call CheckDefExecAndScriptFailure(["var x = -{a: 1}"], ["E1012:", 'E728:'], 1)
call CheckDefAndScriptFailure(["var x = @"], "E1002:", 1)
call CheckDefAndScriptFailure(["var x = @<"], "E354:", 1)
@ -3181,29 +3181,29 @@ func Test_expr7_fails()
call CheckDefFailure(["var x = [1, 2"], "E697:", 2)
call CheckScriptFailure(['vim9script', "var x = [1, 2"], 'E696:', 2)
call CheckDefAndScriptFailure2(["var x = [notfound]"], "E1001:", 'E121:', 1)
call CheckDefAndScriptFailure(["var x = [notfound]"], ["E1001:", 'E121:'], 1)
call CheckDefAndScriptFailure(["var X = () => 123)"], 'E488:', 1)
call CheckDefAndScriptFailure(["var x = 123->((x) => x + 5)"], "E107:", 1)
call CheckDefAndScriptFailure(["var x = &notexist"], 'E113:', 1)
call CheckDefAndScriptFailure2(["&grepprg = [343]"], 'E1012:', 'E730:', 1)
call CheckDefAndScriptFailure(["&grepprg = [343]"], ['E1012:', 'E730:'], 1)
call CheckDefExecAndScriptFailure(["echo s:doesnt_exist"], 'E121:', 1)
call CheckDefExecAndScriptFailure(["echo g:doesnt_exist"], 'E121:', 1)
call CheckDefAndScriptFailure2(["echo a:somevar"], 'E1075:', 'E121:', 1)
call CheckDefAndScriptFailure2(["echo l:somevar"], 'E1075:', 'E121:', 1)
call CheckDefAndScriptFailure2(["echo x:somevar"], 'E1075:', 'E121:', 1)
call CheckDefAndScriptFailure(["echo a:somevar"], ['E1075:', 'E121:'], 1)
call CheckDefAndScriptFailure(["echo l:somevar"], ['E1075:', 'E121:'], 1)
call CheckDefAndScriptFailure(["echo x:somevar"], ['E1075:', 'E121:'], 1)
call CheckDefExecAndScriptFailure2(["var x = +g:astring"], 'E1012:', 'E1030:', 1)
call CheckDefExecAndScriptFailure2(["var x = +g:ablob"], 'E1012:', 'E974:', 1)
call CheckDefExecAndScriptFailure2(["var x = +g:alist"], 'E1012:', 'E745:', 1)
call CheckDefExecAndScriptFailure2(["var x = +g:adict"], 'E1012:', 'E728:', 1)
call CheckDefExecAndScriptFailure(["var x = +g:astring"], ['E1012:', 'E1030:'], 1)
call CheckDefExecAndScriptFailure(["var x = +g:ablob"], ['E1012:', 'E974:'], 1)
call CheckDefExecAndScriptFailure(["var x = +g:alist"], ['E1012:', 'E745:'], 1)
call CheckDefExecAndScriptFailure(["var x = +g:adict"], ['E1012:', 'E728:'], 1)
call CheckDefAndScriptFailure2(["var x = ''", "var y = x.memb"], 'E1229: Expected dictionary for using key "memb", but got string', 'E488:', 2)
call CheckDefAndScriptFailure(["var x = ''", "var y = x.memb"], ['E1229: Expected dictionary for using key "memb", but got string', 'E488:'], 2)
call CheckDefAndScriptFailure2(["'yes'->", "Echo()"], 'E488: Trailing characters: ->', 'E260: Missing name after ->', 1)
call CheckDefAndScriptFailure(["'yes'->", "Echo()"], ['E488: Trailing characters: ->', 'E260: Missing name after ->'], 1)
call CheckDefExecFailure(["[1, 2->len()"], 'E697:', 2)
call CheckScriptFailure(['vim9script', "[1, 2->len()"], 'E696:', 2)
@ -3327,7 +3327,7 @@ def Test_expr7_string_subscript()
lines =<< trim END
var d = 'asdf'[1 : xxx]
END
CheckDefAndScriptFailure2(lines, 'E1001:', 'E121:', 1)
CheckDefAndScriptFailure(lines, ['E1001:', 'E121:'], 1)
lines =<< trim END
var d = 'asdf'[1 : 2
@ -3345,19 +3345,19 @@ def Test_expr7_string_subscript()
var d = 'asdf'['1']
echo d
END
CheckDefAndScriptFailure2(lines, 'E1012: Type mismatch; expected number but got string', 'E1030: Using a String as a Number: "1"', 1)
CheckDefAndScriptFailure(lines, ['E1012: Type mismatch; expected number but got string', 'E1030: Using a String as a Number: "1"'], 1)
lines =<< trim END
var d = 'asdf'['1' : 2]
echo d
END
CheckDefAndScriptFailure2(lines, 'E1012: Type mismatch; expected number but got string', 'E1030: Using a String as a Number: "1"', 1)
CheckDefAndScriptFailure(lines, ['E1012: Type mismatch; expected number but got string', 'E1030: Using a String as a Number: "1"'], 1)
lines =<< trim END
var d = 'asdf'[1 : '2']
echo d
END
CheckDefAndScriptFailure2(lines, 'E1012: Type mismatch; expected number but got string', 'E1030: Using a String as a Number: "2"', 1)
CheckDefAndScriptFailure(lines, ['E1012: Type mismatch; expected number but got string', 'E1030: Using a String as a Number: "2"'], 1)
enddef
def Test_expr7_list_subscript()
@ -3391,7 +3391,7 @@ def Test_expr7_list_subscript()
CheckDefAndScriptSuccess(lines)
lines = ['var l = [0, 1, 2]', 'echo l[g:astring : g:theone]']
CheckDefExecAndScriptFailure2(lines, 'E1012:', 'E1030:', 2)
CheckDefExecAndScriptFailure(lines, ['E1012:', 'E1030:'], 2)
lines =<< trim END
var ld = []
@ -3476,7 +3476,7 @@ def Test_expr7_subscript_linebreak()
assert_equal(33, d.
one)
END
CheckDefAndScriptFailure2(lines, 'E1127:', 'E116:', 2)
CheckDefAndScriptFailure(lines, ['E1127:', 'E116:'], 2)
enddef
func Test_expr7_trailing_fails()
@ -3488,18 +3488,18 @@ func Test_expr_fails()
call CheckDefAndScriptFailure(["var x = '1'is2"], 'E488:', 1)
call CheckDefAndScriptFailure(["var x = '1'isnot2"], 'E488:', 1)
call CheckDefAndScriptFailure2(["CallMe ('yes')"], 'E476:', 'E492:', 1)
call CheckDefAndScriptFailure(["CallMe ('yes')"], ['E476:', 'E492:'], 1)
call CheckDefAndScriptFailure(["CallMe2('yes','no')"], 'E1069:', 1)
call CheckDefAndScriptFailure2(["v:nosuch += 3"], 'E1001:', 'E121:', 1)
call CheckDefAndScriptFailure(["v:nosuch += 3"], ['E1001:', 'E121:'], 1)
call CheckDefAndScriptFailure(["var v:statusmsg = ''"], 'E1016: Cannot declare a v: variable:', 1)
call CheckDefAndScriptFailure2(["var asdf = v:nosuch"], 'E1001:', 'E121:', 1)
call CheckDefAndScriptFailure(["var asdf = v:nosuch"], ['E1001:', 'E121:'], 1)
call CheckDefFailure(["echo len('asdf'"], 'E110:', 2)
call CheckScriptFailure(['vim9script', "echo len('asdf'"], 'E116:', 2)
call CheckDefAndScriptFailure2(["echo Func0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789()"], 'E1011:', 'E117:', 1)
call CheckDefAndScriptFailure(["echo Func0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789()"], ['E1011:', 'E117:'], 1)
call CheckDefAndScriptFailure(["echo doesnotexist()"], 'E117:', 1)
endfunc

View File

@ -491,7 +491,7 @@ def Test_call_varargs()
enddef
def Test_call_white_space()
CheckDefAndScriptFailure2(["call Test ('text')"], 'E476:', 'E1068:')
CheckDefAndScriptFailure(["call Test ('text')"], ['E476:', 'E1068:'])
enddef
def MyDefaultArgs(name = 'string'): string

View File

@ -1511,7 +1511,7 @@ def Test_import_star_fails()
import * as foo from './Xfoo.vim'
foo = 'bar'
END
CheckDefAndScriptFailure2(lines, 'E1094:', 'E1236: Cannot use foo itself')
CheckDefAndScriptFailure(lines, ['E1094:', 'E1236: Cannot use foo itself'])
lines =<< trim END
vim9script
import * as foo from './Xfoo.vim'
@ -1549,7 +1549,7 @@ def Test_import_star_fails()
import * as That from './Xthat.vim'
That()
END
CheckDefAndScriptFailure2(lines, 'E1094:', 'E1236: Cannot use That itself')
CheckDefAndScriptFailure(lines, ['E1094:', 'E1236: Cannot use That itself'])
delete('Xthat.vim')
enddef
@ -2852,12 +2852,12 @@ def Test_for_loop_with_closure()
enddef
def Test_for_loop_fails()
CheckDefAndScriptFailure2(['for '], 'E1097:', 'E690:')
CheckDefAndScriptFailure2(['for x'], 'E1097:', 'E690:')
CheckDefAndScriptFailure2(['for x in'], 'E1097:', 'E15:')
CheckDefAndScriptFailure(['for '], ['E1097:', 'E690:'])
CheckDefAndScriptFailure(['for x'], ['E1097:', 'E690:'])
CheckDefAndScriptFailure(['for x in'], ['E1097:', 'E15:'])
CheckDefAndScriptFailure(['for # in range(5)'], 'E690:')
CheckDefAndScriptFailure(['for i In range(5)'], 'E690:')
CheckDefAndScriptFailure2(['var x = 5', 'for x in range(5)', 'endfor'], 'E1017:', 'E1041:')
CheckDefAndScriptFailure(['var x = 5', 'for x in range(5)', 'endfor'], ['E1017:', 'E1041:'])
CheckScriptFailure(['vim9script', 'var x = 5', 'for x in range(5)', '# comment', 'endfor'], 'E1041:', 3)
CheckScriptFailure(['def Func(arg: any)', 'for arg in range(5)', 'enddef', 'defcompile'], 'E1006:')
delfunc! g:Func
@ -2879,7 +2879,7 @@ def Test_for_loop_fails()
e = {a: 0, b: ''}
endfor
END
CheckDefAndScriptFailure2(lines, 'E1018:', 'E46:', 3)
CheckDefAndScriptFailure(lines, ['E1018:', 'E46:'], 3)
lines =<< trim END
for nr: number in ['foo']
@ -2908,7 +2908,7 @@ def Test_for_loop_fails()
echo i
endfor
END
CheckDefExecAndScriptFailure2(lines, 'E1017:', 'E1041:')
CheckDefExecAndScriptFailure(lines, ['E1017:', 'E1041:'])
lines =<< trim END
var l = [0]
@ -2916,7 +2916,7 @@ def Test_for_loop_fails()
echo l[0]
endfor
END
CheckDefExecAndScriptFailure2(lines, 'E461:', 'E1017:')
CheckDefExecAndScriptFailure(lines, ['E461:', 'E1017:'])
lines =<< trim END
var d = {x: 0}
@ -2924,7 +2924,7 @@ def Test_for_loop_fails()
echo d.x
endfor
END
CheckDefExecAndScriptFailure2(lines, 'E461:', 'E1017:')
CheckDefExecAndScriptFailure(lines, ['E461:', 'E1017:'])
enddef
def Test_for_loop_script_var()

View File

@ -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

View File

@ -749,6 +749,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3854,
/**/
3853,
/**/