mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.2.1623: Vim9: using :call where it is not needed
Problem: Vim9: using :call where it is not needed. Solution: Remove :call. (closes #6892)
This commit is contained in:
@@ -90,7 +90,7 @@ def Test_vim9_maparg()
|
||||
let three: string = maparg('{', 'n', 0)
|
||||
assert_equal('w', three)
|
||||
let four: dict<any> = maparg('{', 'n', 0, 1)
|
||||
call assert_equal(['{', 'w', 'n'], [four.lhs, four.rhs, four.mode])
|
||||
assert_equal(['{', 'w', 'n'], [four.lhs, four.rhs, four.mode])
|
||||
nunmap {
|
||||
enddef
|
||||
|
||||
|
@@ -334,10 +334,10 @@ enddef
|
||||
|
||||
def Test_prop_remove_vim9()
|
||||
new
|
||||
call AddPropTypes()
|
||||
call SetupPropsInFirstLine()
|
||||
call assert_equal(1, prop_remove({'type': 'three', 'id': 13, 'both': true, 'all': true}))
|
||||
call DeletePropTypes()
|
||||
AddPropTypes()
|
||||
SetupPropsInFirstLine()
|
||||
assert_equal(1, prop_remove({'type': 'three', 'id': 13, 'both': true, 'all': true}))
|
||||
DeletePropTypes()
|
||||
bwipe!
|
||||
enddef
|
||||
|
||||
|
@@ -558,7 +558,7 @@ def HasSomething()
|
||||
enddef
|
||||
|
||||
def Test_disassemble_const_expr()
|
||||
assert_equal("\nyes", execute('call HasEval()'))
|
||||
assert_equal("\nyes", execute('HasEval()'))
|
||||
let instr = execute('disassemble HasEval')
|
||||
assert_match('HasEval\_s*' ..
|
||||
'if has("eval")\_s*' ..
|
||||
@@ -571,7 +571,7 @@ def Test_disassemble_const_expr()
|
||||
instr)
|
||||
assert_notmatch('JUMP', instr)
|
||||
|
||||
assert_equal("\nno", execute('call HasNothing()'))
|
||||
assert_equal("\nno", execute('HasNothing()'))
|
||||
instr = execute('disassemble HasNothing')
|
||||
assert_match('HasNothing\_s*' ..
|
||||
'if has("nothing")\_s*' ..
|
||||
@@ -585,7 +585,7 @@ def Test_disassemble_const_expr()
|
||||
assert_notmatch('PUSHS "yes"', instr)
|
||||
assert_notmatch('JUMP', instr)
|
||||
|
||||
assert_equal("\neval", execute('call HasSomething()'))
|
||||
assert_equal("\neval", execute('HasSomething()'))
|
||||
instr = execute('disassemble HasSomething')
|
||||
assert_match('HasSomething.*' ..
|
||||
'if has("nothing")\_s*' ..
|
||||
@@ -1088,7 +1088,7 @@ def Test_disassemble_dict_member()
|
||||
'\d\+ MEMBER\_s*' ..
|
||||
'\d\+ STORE $1\_s*',
|
||||
instr)
|
||||
call assert_equal(1, DictMember())
|
||||
assert_equal(1, DictMember())
|
||||
enddef
|
||||
|
||||
let somelist = [1, 2, 3, 4, 5]
|
||||
@@ -1156,7 +1156,7 @@ def Test_disassemble_negate_number()
|
||||
'\d NEGATENR\_s*' ..
|
||||
'\d STORE $2\_s*',
|
||||
instr)
|
||||
call assert_equal(-9, NegateNumber())
|
||||
assert_equal(-9, NegateNumber())
|
||||
enddef
|
||||
|
||||
def InvertBool(): bool
|
||||
@@ -1181,7 +1181,7 @@ def Test_disassemble_invert_bool()
|
||||
'\d 2BOOL (!!val)\_s*' ..
|
||||
'\d STORE $2\_s*',
|
||||
instr)
|
||||
call assert_equal(true, InvertBool())
|
||||
assert_equal(true, InvertBool())
|
||||
enddef
|
||||
|
||||
def Test_disassemble_compare()
|
||||
|
@@ -122,7 +122,7 @@ def Test_expr1_vimscript()
|
||||
lines =<< trim END
|
||||
vim9script
|
||||
try
|
||||
call eval('0 ? 1: 2')
|
||||
eval('0 ? 1: 2')
|
||||
catch
|
||||
endtry
|
||||
assert_equal(v:true, eval(string(v:true)))
|
||||
@@ -132,7 +132,7 @@ def Test_expr1_vimscript()
|
||||
lines =<< trim END
|
||||
vim9script
|
||||
try
|
||||
call eval('0 ? 1 :2')
|
||||
eval('0 ? 1 :2')
|
||||
catch
|
||||
endtry
|
||||
assert_equal(v:true, eval(string(v:true)))
|
||||
@@ -480,7 +480,7 @@ def Test_expr4_equal()
|
||||
assert_equal(false, 'abc' ==# 'ABC')
|
||||
set noignorecase
|
||||
|
||||
call CheckDefFailure(["let x = 'a' == xxx"], 'E1001:', 1)
|
||||
CheckDefFailure(["let x = 'a' == xxx"], 'E1001:', 1)
|
||||
|
||||
let bb = 0z3f
|
||||
assert_equal(true, 0z3f == bb)
|
||||
@@ -1225,7 +1225,7 @@ def Test_expr6()
|
||||
* yf[0])
|
||||
endif
|
||||
|
||||
call CheckDefFailure(["let x = 6 * xxx"], 'E1001', 1)
|
||||
CheckDefFailure(["let x = 6 * xxx"], 'E1001', 1)
|
||||
enddef
|
||||
|
||||
def Test_expr6_vim9script()
|
||||
@@ -1382,9 +1382,9 @@ def Test_expr7t()
|
||||
let nr = <number>234
|
||||
assert_equal(234, nr)
|
||||
|
||||
call CheckDefFailure(["let x = <nr>123"], 'E1010:', 1)
|
||||
call CheckDefFailure(["let x = <number >123"], 'E1068:', 1)
|
||||
call CheckDefFailure(["let x = <number 123"], 'E1104:', 1)
|
||||
CheckDefFailure(["let x = <nr>123"], 'E1010:', 1)
|
||||
CheckDefFailure(["let x = <number >123"], 'E1068:', 1)
|
||||
CheckDefFailure(["let x = <number 123"], 'E1104:', 1)
|
||||
enddef
|
||||
|
||||
" test low level expression
|
||||
@@ -1416,7 +1416,7 @@ def Test_expr7_blob()
|
||||
assert_equal(g:blob_one, 0z01)
|
||||
assert_equal(g:blob_long, 0z0102.0304)
|
||||
|
||||
call CheckDefFailure(["let x = 0z123"], 'E973:', 1)
|
||||
CheckDefFailure(["let x = 0z123"], 'E973:', 1)
|
||||
enddef
|
||||
|
||||
def Test_expr7_string()
|
||||
@@ -1429,16 +1429,16 @@ def Test_expr7_string()
|
||||
assert_equal(g:string_long, "abcdefghijklm")
|
||||
assert_equal(g:string_special, "ab\ncd\ref\ekk")
|
||||
|
||||
call CheckDefFailure(['let x = "abc'], 'E114:', 1)
|
||||
call CheckDefFailure(["let x = 'abc"], 'E115:', 1)
|
||||
CheckDefFailure(['let x = "abc'], 'E114:', 1)
|
||||
CheckDefFailure(["let x = 'abc"], 'E115:', 1)
|
||||
enddef
|
||||
|
||||
def Test_expr7_vimvar()
|
||||
let old: list<string> = v:oldfiles
|
||||
let compl: dict<any> = v:completed_item
|
||||
|
||||
call CheckDefFailure(["let old: list<number> = v:oldfiles"], 'E1012: type mismatch, expected list<number> but got list<string>', 1)
|
||||
call CheckDefFailure(["let old: dict<number> = v:completed_item"], 'E1012: type mismatch, expected dict<number> but got dict<any>', 1)
|
||||
CheckDefFailure(["let old: list<number> = v:oldfiles"], 'E1012: type mismatch, expected list<number> but got list<string>', 1)
|
||||
CheckDefFailure(["let old: dict<number> = v:completed_item"], 'E1012: type mismatch, expected dict<number> but got dict<any>', 1)
|
||||
enddef
|
||||
|
||||
def Test_expr7_special()
|
||||
@@ -1460,11 +1460,11 @@ def Test_expr7_special()
|
||||
assert_equal(g:special_null, v:null)
|
||||
assert_equal(g:special_none, v:none)
|
||||
|
||||
call CheckDefFailure(['v:true = true'], 'E46:', 1)
|
||||
call CheckDefFailure(['v:true = false'], 'E46:', 1)
|
||||
call CheckDefFailure(['v:false = true'], 'E46:', 1)
|
||||
call CheckDefFailure(['v:null = 11'], 'E46:', 1)
|
||||
call CheckDefFailure(['v:none = 22'], 'E46:', 1)
|
||||
CheckDefFailure(['v:true = true'], 'E46:', 1)
|
||||
CheckDefFailure(['v:true = false'], 'E46:', 1)
|
||||
CheckDefFailure(['v:false = true'], 'E46:', 1)
|
||||
CheckDefFailure(['v:null = 11'], 'E46:', 1)
|
||||
CheckDefFailure(['v:none = 22'], 'E46:', 1)
|
||||
enddef
|
||||
|
||||
def Test_expr7_special_vim9script()
|
||||
@@ -1509,24 +1509,24 @@ def Test_expr7_list()
|
||||
2] [3,
|
||||
4]
|
||||
|
||||
call CheckDefFailure(["let x = 1234[3]"], 'E1107:', 1)
|
||||
call CheckDefExecFailure(["let x = g:anint[3]"], 'E1062:', 1)
|
||||
CheckDefFailure(["let x = 1234[3]"], 'E1107:', 1)
|
||||
CheckDefExecFailure(["let x = g:anint[3]"], 'E1062:', 1)
|
||||
|
||||
call CheckDefFailure(["let x = g:list_mixed[xxx]"], 'E1001:', 1)
|
||||
CheckDefFailure(["let x = g:list_mixed[xxx]"], 'E1001:', 1)
|
||||
|
||||
call CheckDefFailure(["let x = [1,2,3]"], 'E1069:', 1)
|
||||
call CheckDefFailure(["let x = [1 ,2, 3]"], 'E1068:', 1)
|
||||
CheckDefFailure(["let x = [1,2,3]"], 'E1069:', 1)
|
||||
CheckDefFailure(["let x = [1 ,2, 3]"], 'E1068:', 1)
|
||||
|
||||
call CheckDefExecFailure(["echo 1", "let x = [][0]", "echo 3"], 'E684:', 2)
|
||||
CheckDefExecFailure(["echo 1", "let x = [][0]", "echo 3"], 'E684:', 2)
|
||||
|
||||
call CheckDefExecFailure(["let x = g:list_mixed['xx']"], 'E1029:', 1)
|
||||
call CheckDefFailure(["let x = g:list_mixed["], 'E1097:', 2)
|
||||
call CheckDefFailure(["let x = g:list_mixed[0"], 'E1097:', 2)
|
||||
call CheckDefExecFailure(["let x = g:list_empty[3]"], 'E684:', 1)
|
||||
call CheckDefFailure(["let l: list<number> = [234, 'x']"], 'E1012:', 1)
|
||||
call CheckDefFailure(["let l: list<number> = ['x', 234]"], 'E1012:', 1)
|
||||
call CheckDefFailure(["let l: list<string> = [234, 'x']"], 'E1012:', 1)
|
||||
call CheckDefFailure(["let l: list<string> = ['x', 123]"], 'E1012:', 1)
|
||||
CheckDefExecFailure(["let x = g:list_mixed['xx']"], 'E1029:', 1)
|
||||
CheckDefFailure(["let x = g:list_mixed["], 'E1097:', 2)
|
||||
CheckDefFailure(["let x = g:list_mixed[0"], 'E1097:', 2)
|
||||
CheckDefExecFailure(["let x = g:list_empty[3]"], 'E684:', 1)
|
||||
CheckDefFailure(["let l: list<number> = [234, 'x']"], 'E1012:', 1)
|
||||
CheckDefFailure(["let l: list<number> = ['x', 234]"], 'E1012:', 1)
|
||||
CheckDefFailure(["let l: list<string> = [234, 'x']"], 'E1012:', 1)
|
||||
CheckDefFailure(["let l: list<string> = ['x', 123]"], 'E1012:', 1)
|
||||
enddef
|
||||
|
||||
def Test_expr7_list_vim9script()
|
||||
@@ -1647,9 +1647,9 @@ def Test_expr7_lambda()
|
||||
assert_equal(false, LambdaUsingArg(0)())
|
||||
assert_equal(true, LambdaUsingArg(1)())
|
||||
|
||||
call CheckDefFailure(["filter([1, 2], {k,v -> 1})"], 'E1069:', 1)
|
||||
CheckDefFailure(["filter([1, 2], {k,v -> 1})"], 'E1069:', 1)
|
||||
# error is in first line of the lambda
|
||||
call CheckDefFailure(["let L = {a -> a + b}"], 'E1001:', 0)
|
||||
CheckDefFailure(["let L = {a -> a + b}"], 'E1001:', 0)
|
||||
|
||||
assert_equal('xxxyyy', 'xxx'->{a, b -> a .. b}('yyy'))
|
||||
|
||||
@@ -1714,26 +1714,26 @@ def Test_expr7_dict()
|
||||
mixed = #{a: 234}
|
||||
mixed = #{}
|
||||
|
||||
call CheckDefFailure(["let x = #{a:8}"], 'E1069:', 1)
|
||||
call CheckDefFailure(["let x = #{a : 8}"], 'E1068:', 1)
|
||||
call CheckDefFailure(["let x = #{a :8}"], 'E1068:', 1)
|
||||
call CheckDefFailure(["let x = #{a: 8 , b: 9}"], 'E1068:', 1)
|
||||
CheckDefFailure(["let x = #{a:8}"], 'E1069:', 1)
|
||||
CheckDefFailure(["let x = #{a : 8}"], 'E1068:', 1)
|
||||
CheckDefFailure(["let x = #{a :8}"], 'E1068:', 1)
|
||||
CheckDefFailure(["let x = #{a: 8 , b: 9}"], 'E1068:', 1)
|
||||
|
||||
call CheckDefFailure(["let x = #{8: 8}"], 'E1014:', 1)
|
||||
call CheckDefFailure(["let x = #{xxx}"], 'E720:', 1)
|
||||
call CheckDefFailure(["let x = #{xxx: 1", "let y = 2"], 'E722:', 2)
|
||||
call CheckDefFailure(["let x = #{xxx: 1,"], 'E723:', 2)
|
||||
call CheckDefFailure(["let x = {'a': xxx}"], 'E1001:', 1)
|
||||
call CheckDefFailure(["let x = {xxx: 8}"], 'E1001:', 1)
|
||||
call CheckDefFailure(["let x = #{a: 1, a: 2}"], 'E721:', 1)
|
||||
call CheckDefFailure(["let x = #"], 'E1015:', 1)
|
||||
call CheckDefExecFailure(["let x = g:anint.member"], 'E715:', 1)
|
||||
call CheckDefExecFailure(["let x = g:dict_empty.member"], 'E716:', 1)
|
||||
CheckDefFailure(["let x = #{8: 8}"], 'E1014:', 1)
|
||||
CheckDefFailure(["let x = #{xxx}"], 'E720:', 1)
|
||||
CheckDefFailure(["let x = #{xxx: 1", "let y = 2"], 'E722:', 2)
|
||||
CheckDefFailure(["let x = #{xxx: 1,"], 'E723:', 2)
|
||||
CheckDefFailure(["let x = {'a': xxx}"], 'E1001:', 1)
|
||||
CheckDefFailure(["let x = {xxx: 8}"], 'E1001:', 1)
|
||||
CheckDefFailure(["let x = #{a: 1, a: 2}"], 'E721:', 1)
|
||||
CheckDefFailure(["let x = #"], 'E1015:', 1)
|
||||
CheckDefExecFailure(["let x = g:anint.member"], 'E715:', 1)
|
||||
CheckDefExecFailure(["let x = g:dict_empty.member"], 'E716:', 1)
|
||||
|
||||
call CheckDefFailure(['let x: dict<number> = #{a: 234, b: "1"}'], 'E1012:', 1)
|
||||
call CheckDefFailure(['let x: dict<number> = #{a: "x", b: 134}'], 'E1012:', 1)
|
||||
call CheckDefFailure(['let x: dict<string> = #{a: 234, b: "1"}'], 'E1012:', 1)
|
||||
call CheckDefFailure(['let x: dict<string> = #{a: "x", b: 134}'], 'E1012:', 1)
|
||||
CheckDefFailure(['let x: dict<number> = #{a: 234, b: "1"}'], 'E1012:', 1)
|
||||
CheckDefFailure(['let x: dict<number> = #{a: "x", b: 134}'], 'E1012:', 1)
|
||||
CheckDefFailure(['let x: dict<string> = #{a: 234, b: "1"}'], 'E1012:', 1)
|
||||
CheckDefFailure(['let x: dict<string> = #{a: "x", b: 134}'], 'E1012:', 1)
|
||||
enddef
|
||||
|
||||
def Test_expr7_dict_vim9script()
|
||||
@@ -1837,9 +1837,9 @@ def Test_expr_member()
|
||||
assert_equal('one', #{one: 'one'}.one)
|
||||
assert_equal('one', #{one: 'one'}[g:oneString])
|
||||
|
||||
call CheckDefFailure(["let x = g:dict_one.#$!"], 'E1002:', 1)
|
||||
call CheckDefExecFailure(["let d: dict<any>", "echo d['a']"], 'E716:', 2)
|
||||
call CheckDefExecFailure(["let d: dict<number>", "d = g:list_empty"], 'E1029: Expected dict but got list', 2)
|
||||
CheckDefFailure(["let x = g:dict_one.#$!"], 'E1002:', 1)
|
||||
CheckDefExecFailure(["let d: dict<any>", "echo d['a']"], 'E716:', 2)
|
||||
CheckDefExecFailure(["let d: dict<number>", "d = g:list_empty"], 'E1029: Expected dict but got list', 2)
|
||||
enddef
|
||||
|
||||
def Test_expr7_any_index_slice()
|
||||
@@ -1991,7 +1991,7 @@ def Test_expr7_environment()
|
||||
assert_equal('testvar', $TESTVAR)
|
||||
assert_equal('', $ASDF_ASD_XXX)
|
||||
|
||||
call CheckDefFailure(["let x = $$$"], 'E1002:', 1)
|
||||
CheckDefFailure(["let x = $$$"], 'E1002:', 1)
|
||||
enddef
|
||||
|
||||
def Test_expr7_register()
|
||||
@@ -2006,7 +2006,7 @@ def Test_expr7_register()
|
||||
|
||||
normal axyz
|
||||
assert_equal("xyz", @.)
|
||||
call CheckDefFailure(["@. = 'yes'"], 'E354:', 1)
|
||||
CheckDefFailure(["@. = 'yes'"], 'E354:', 1)
|
||||
|
||||
@/ = 'slash'
|
||||
assert_equal('slash', @/)
|
||||
@@ -2091,11 +2091,11 @@ def Test_expr7_call()
|
||||
assert_equal(true, !range(5)->empty())
|
||||
assert_equal([0, 1, 2], --3->range())
|
||||
|
||||
call CheckDefFailure(["let x = 'yes'->Echo"], 'E107:', 1)
|
||||
call CheckScriptFailure([
|
||||
"vim9script",
|
||||
"let x = substitute ('x', 'x', 'x', 'x')"
|
||||
], 'E121:', 2)
|
||||
CheckDefFailure(["let x = 'yes'->Echo"], 'E107:', 1)
|
||||
CheckScriptFailure([
|
||||
"vim9script",
|
||||
"let x = substitute ('x', 'x', 'x', 'x')"
|
||||
], 'E121:', 2)
|
||||
|
||||
let auto_lines =<< trim END
|
||||
def g:some#func(): string
|
||||
|
@@ -29,7 +29,7 @@ enddef
|
||||
def Test_return_something()
|
||||
assert_equal('string', ReturnString())
|
||||
assert_equal(123, ReturnNumber())
|
||||
assert_fails('call ReturnGlobal()', 'E1029: Expected number but got string')
|
||||
assert_fails('ReturnGlobal()', 'E1029: Expected number but got string')
|
||||
enddef
|
||||
|
||||
def Test_missing_return()
|
||||
@@ -111,7 +111,7 @@ enddef
|
||||
def Test_call_default_args()
|
||||
assert_equal('string', MyDefaultArgs())
|
||||
assert_equal('one', MyDefaultArgs('one'))
|
||||
assert_fails('call MyDefaultArgs("one", "two")', 'E118:')
|
||||
assert_fails('MyDefaultArgs("one", "two")', 'E118:')
|
||||
|
||||
assert_equal('test', MyDefaultSecond('test'))
|
||||
assert_equal('test', MyDefaultSecond('test', true))
|
||||
@@ -219,10 +219,10 @@ func TakesOneArg(arg)
|
||||
endfunc
|
||||
|
||||
def Test_call_wrong_args()
|
||||
call CheckDefFailure(['TakesOneArg()'], 'E119:')
|
||||
call CheckDefFailure(['TakesOneArg(11, 22)'], 'E118:')
|
||||
call CheckDefFailure(['bufnr(xxx)'], 'E1001:')
|
||||
call CheckScriptFailure(['def Func(Ref: func(s: string))'], 'E475:')
|
||||
CheckDefFailure(['TakesOneArg()'], 'E119:')
|
||||
CheckDefFailure(['TakesOneArg(11, 22)'], 'E118:')
|
||||
CheckDefFailure(['bufnr(xxx)'], 'E1001:')
|
||||
CheckScriptFailure(['def Func(Ref: func(s: string))'], 'E475:')
|
||||
|
||||
let lines =<< trim END
|
||||
vim9script
|
||||
@@ -244,7 +244,7 @@ def MyDefVarargs(one: string, two = 'foo', ...rest: list<string>): string
|
||||
enddef
|
||||
|
||||
def Test_call_def_varargs()
|
||||
call assert_fails('call MyDefVarargs()', 'E119:')
|
||||
assert_fails('MyDefVarargs()', 'E119:')
|
||||
assert_equal('one,foo', MyDefVarargs('one'))
|
||||
assert_equal('one,two', MyDefVarargs('one', 'two'))
|
||||
assert_equal('one,two,three', MyDefVarargs('one', 'two', 'three'))
|
||||
@@ -333,8 +333,8 @@ def Test_func_type_varargs()
|
||||
assert_equal('99text', RefDef2Arg(99))
|
||||
assert_equal('77some', RefDef2Arg(77, 'some'))
|
||||
|
||||
call CheckDefFailure(['let RefWrong: func(string?)'], 'E1010:')
|
||||
call CheckDefFailure(['let RefWrong: func(?string, string)'], 'E1007:')
|
||||
CheckDefFailure(['let RefWrong: func(string?)'], 'E1010:')
|
||||
CheckDefFailure(['let RefWrong: func(?string, string)'], 'E1007:')
|
||||
|
||||
let RefVarargs: func(...list<string>): string
|
||||
RefVarargs = FuncVarargs
|
||||
@@ -342,8 +342,8 @@ def Test_func_type_varargs()
|
||||
assert_equal('one', RefVarargs('one'))
|
||||
assert_equal('one,two', RefVarargs('one', 'two'))
|
||||
|
||||
call CheckDefFailure(['let RefWrong: func(...list<string>, string)'], 'E110:')
|
||||
call CheckDefFailure(['let RefWrong: func(...list<string>, ?string)'], 'E110:')
|
||||
CheckDefFailure(['let RefWrong: func(...list<string>, string)'], 'E110:')
|
||||
CheckDefFailure(['let RefWrong: func(...list<string>, ?string)'], 'E110:')
|
||||
enddef
|
||||
|
||||
" Only varargs
|
||||
@@ -355,14 +355,14 @@ def Test_call_varargs_only()
|
||||
assert_equal('', MyVarargsOnly())
|
||||
assert_equal('one', MyVarargsOnly('one'))
|
||||
assert_equal('one,two', MyVarargsOnly('one', 'two'))
|
||||
call CheckDefFailure(['MyVarargsOnly(1)'], 'E1013: argument 1: type mismatch, expected string but got number')
|
||||
call CheckDefFailure(['MyVarargsOnly("one", 2)'], 'E1013: argument 2: type mismatch, expected string but got number')
|
||||
CheckDefFailure(['MyVarargsOnly(1)'], 'E1013: argument 1: type mismatch, expected string but got number')
|
||||
CheckDefFailure(['MyVarargsOnly("one", 2)'], 'E1013: argument 2: type mismatch, expected string but got number')
|
||||
enddef
|
||||
|
||||
def Test_using_var_as_arg()
|
||||
call writefile(['def Func(x: number)', 'let x = 234', 'enddef', 'defcompile'], 'Xdef')
|
||||
call assert_fails('so Xdef', 'E1006:')
|
||||
call delete('Xdef')
|
||||
writefile(['def Func(x: number)', 'let x = 234', 'enddef', 'defcompile'], 'Xdef')
|
||||
assert_fails('so Xdef', 'E1006:')
|
||||
delete('Xdef')
|
||||
enddef
|
||||
|
||||
def DictArg(arg: dict<string>)
|
||||
@@ -382,12 +382,12 @@ def Test_assign_to_argument()
|
||||
ListArg(l)
|
||||
assert_equal('value', l[0])
|
||||
|
||||
call CheckScriptFailure(['def Func(arg: number)', 'arg = 3', 'enddef', 'defcompile'], 'E1090:')
|
||||
CheckScriptFailure(['def Func(arg: number)', 'arg = 3', 'enddef', 'defcompile'], 'E1090:')
|
||||
enddef
|
||||
|
||||
def Test_call_func_defined_later()
|
||||
call assert_equal('one', g:DefinedLater('one'))
|
||||
call assert_fails('call NotDefined("one")', 'E117:')
|
||||
assert_equal('one', g:DefinedLater('one'))
|
||||
assert_fails('NotDefined("one")', 'E117:')
|
||||
enddef
|
||||
|
||||
func DefinedLater(arg)
|
||||
@@ -523,7 +523,7 @@ enddef
|
||||
|
||||
def Test_error_in_nested_function()
|
||||
# Error in called function requires unwinding the call stack.
|
||||
assert_fails('call FuncWithForwardCall()', 'E1096:')
|
||||
assert_fails('FuncWithForwardCall()', 'E1096:')
|
||||
enddef
|
||||
|
||||
def Test_return_type_wrong()
|
||||
@@ -742,19 +742,19 @@ def Test_delfunc()
|
||||
enddef
|
||||
|
||||
def Test_redef_failure()
|
||||
call writefile(['def Func0(): string', 'return "Func0"', 'enddef'], 'Xdef')
|
||||
writefile(['def Func0(): string', 'return "Func0"', 'enddef'], 'Xdef')
|
||||
so Xdef
|
||||
call writefile(['def Func1(): string', 'return "Func1"', 'enddef'], 'Xdef')
|
||||
writefile(['def Func1(): string', 'return "Func1"', 'enddef'], 'Xdef')
|
||||
so Xdef
|
||||
call writefile(['def! Func0(): string', 'enddef', 'defcompile'], 'Xdef')
|
||||
call assert_fails('so Xdef', 'E1027:')
|
||||
call writefile(['def Func2(): string', 'return "Func2"', 'enddef'], 'Xdef')
|
||||
writefile(['def! Func0(): string', 'enddef', 'defcompile'], 'Xdef')
|
||||
assert_fails('so Xdef', 'E1027:')
|
||||
writefile(['def Func2(): string', 'return "Func2"', 'enddef'], 'Xdef')
|
||||
so Xdef
|
||||
call delete('Xdef')
|
||||
delete('Xdef')
|
||||
|
||||
call assert_equal(0, g:Func0())
|
||||
call assert_equal('Func1', g:Func1())
|
||||
call assert_equal('Func2', g:Func2())
|
||||
assert_equal(0, g:Func0())
|
||||
assert_equal('Func1', g:Func1())
|
||||
assert_equal('Func2', g:Func2())
|
||||
|
||||
delfunc! Func0
|
||||
delfunc! Func1
|
||||
@@ -960,10 +960,10 @@ def Test_func_type_fails()
|
||||
CheckDefFailure(['let Ref1: func(?bool)', 'Ref1 = FuncTwoArgNoRet'], 'E1012: type mismatch, expected func(?bool) but got func(bool, number)')
|
||||
CheckDefFailure(['let Ref1: func(...bool)', 'Ref1 = FuncTwoArgNoRet'], 'E1012: type mismatch, expected func(...bool) but got func(bool, number)')
|
||||
|
||||
call CheckDefFailure(['let RefWrong: func(string ,number)'], 'E1068:')
|
||||
call CheckDefFailure(['let RefWrong: func(string,number)'], 'E1069:')
|
||||
call CheckDefFailure(['let RefWrong: func(bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool)'], 'E1005:')
|
||||
call CheckDefFailure(['let RefWrong: func(bool):string'], 'E1069:')
|
||||
CheckDefFailure(['let RefWrong: func(string ,number)'], 'E1068:')
|
||||
CheckDefFailure(['let RefWrong: func(string,number)'], 'E1069:')
|
||||
CheckDefFailure(['let RefWrong: func(bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool)'], 'E1005:')
|
||||
CheckDefFailure(['let RefWrong: func(bool):string'], 'E1069:')
|
||||
enddef
|
||||
|
||||
def Test_func_return_type()
|
||||
@@ -1702,7 +1702,7 @@ enddef
|
||||
|
||||
def Test_cmd_modifier()
|
||||
tab echo '0'
|
||||
call CheckDefFailure(['5tab echo 3'], 'E16:')
|
||||
CheckDefFailure(['5tab echo 3'], 'E16:')
|
||||
enddef
|
||||
|
||||
def Test_restore_modifiers()
|
||||
|
@@ -45,13 +45,13 @@ def Test_assignment()
|
||||
let bool2: bool = false
|
||||
assert_equal(v:false, bool2)
|
||||
|
||||
call CheckDefFailure(['let x:string'], 'E1069:')
|
||||
call CheckDefFailure(['let x:string = "x"'], 'E1069:')
|
||||
call CheckDefFailure(['let a:string = "x"'], 'E1069:')
|
||||
call CheckDefFailure(['let lambda = {-> "lambda"}'], 'E704:')
|
||||
CheckDefFailure(['let x:string'], 'E1069:')
|
||||
CheckDefFailure(['let x:string = "x"'], 'E1069:')
|
||||
CheckDefFailure(['let a:string = "x"'], 'E1069:')
|
||||
CheckDefFailure(['let lambda = {-> "lambda"}'], 'E704:')
|
||||
|
||||
let nr: number = 1234
|
||||
call CheckDefFailure(['let nr: number = "asdf"'], 'E1012:')
|
||||
CheckDefFailure(['let nr: number = "asdf"'], 'E1012:')
|
||||
|
||||
let a: number = 6 #comment
|
||||
assert_equal(6, a)
|
||||
@@ -88,7 +88,7 @@ def Test_assignment()
|
||||
assert_equal('barfoo', $ENVVAR)
|
||||
$ENVVAR = ''
|
||||
END
|
||||
call CheckScriptSuccess(lines)
|
||||
CheckScriptSuccess(lines)
|
||||
|
||||
s:appendToMe ..= 'yyy'
|
||||
assert_equal('xxxyyy', s:appendToMe)
|
||||
@@ -175,15 +175,15 @@ def Test_assignment()
|
||||
enddef
|
||||
defcompile
|
||||
END
|
||||
call CheckScriptFailure(lines, 'E1089:')
|
||||
CheckScriptFailure(lines, 'E1089:')
|
||||
|
||||
g:inc_counter += 1
|
||||
assert_equal(2, g:inc_counter)
|
||||
|
||||
$SOME_ENV_VAR ..= 'more'
|
||||
assert_equal('somemore', $SOME_ENV_VAR)
|
||||
call CheckDefFailure(['$SOME_ENV_VAR += "more"'], 'E1051:')
|
||||
call CheckDefFailure(['$SOME_ENV_VAR += 123'], 'E1012:')
|
||||
CheckDefFailure(['$SOME_ENV_VAR += "more"'], 'E1051:')
|
||||
CheckDefFailure(['$SOME_ENV_VAR += 123'], 'E1012:')
|
||||
|
||||
lines =<< trim END
|
||||
@c = 'areg'
|
||||
@@ -192,14 +192,14 @@ def Test_assignment()
|
||||
END
|
||||
CheckDefAndScriptSuccess(lines)
|
||||
|
||||
call CheckDefFailure(['@a += "more"'], 'E1051:')
|
||||
call CheckDefFailure(['@a += 123'], 'E1012:')
|
||||
CheckDefFailure(['@a += "more"'], 'E1051:')
|
||||
CheckDefFailure(['@a += 123'], 'E1012:')
|
||||
|
||||
v:errmsg = 'none'
|
||||
v:errmsg ..= 'again'
|
||||
assert_equal('noneagain', v:errmsg)
|
||||
call CheckDefFailure(['v:errmsg += "more"'], 'E1051:')
|
||||
call CheckDefFailure(['v:errmsg += 123'], 'E1012:')
|
||||
CheckDefFailure(['v:errmsg += "more"'], 'E1051:')
|
||||
CheckDefFailure(['v:errmsg += 123'], 'E1012:')
|
||||
|
||||
# single letter variables
|
||||
a = 123
|
||||
@@ -283,8 +283,8 @@ def Test_assignment_list()
|
||||
assert_equal(['sdf', 'asdf', 'end'], list3)
|
||||
|
||||
|
||||
call CheckDefExecFailure(['let ll = [1, 2, 3]', 'll[-4] = 6'], 'E684:')
|
||||
call CheckDefExecFailure(['let [v1, v2] = [1, 2]'], 'E1092:')
|
||||
CheckDefExecFailure(['let ll = [1, 2, 3]', 'll[-4] = 6'], 'E684:')
|
||||
CheckDefExecFailure(['let [v1, v2] = [1, 2]'], 'E1092:')
|
||||
|
||||
# type becomes list<any>
|
||||
let somelist = rand() > 0 ? [1, 2, 3] : ['a', 'b', 'c']
|
||||
@@ -299,7 +299,7 @@ def Test_assignment_list_vim9script()
|
||||
[v1, v2, v3] = [1, 2, 3]
|
||||
assert_equal([1, 2, 3], [v1, v2, v3])
|
||||
END
|
||||
call CheckScriptSuccess(lines)
|
||||
CheckScriptSuccess(lines)
|
||||
enddef
|
||||
|
||||
def Test_assignment_dict()
|
||||
@@ -534,89 +534,89 @@ def Mess(): string
|
||||
enddef
|
||||
|
||||
def Test_assignment_failure()
|
||||
call CheckDefFailure(['let var=234'], 'E1004:')
|
||||
call CheckDefFailure(['let var =234'], 'E1004:')
|
||||
call CheckDefFailure(['let var= 234'], 'E1004:')
|
||||
CheckDefFailure(['let var=234'], 'E1004:')
|
||||
CheckDefFailure(['let var =234'], 'E1004:')
|
||||
CheckDefFailure(['let var= 234'], 'E1004:')
|
||||
|
||||
call CheckScriptFailure(['vim9script', 'let var=234'], 'E1004:')
|
||||
call CheckScriptFailure(['vim9script', 'let var=234'], "before and after '='")
|
||||
call CheckScriptFailure(['vim9script', 'let var =234'], 'E1004:')
|
||||
call CheckScriptFailure(['vim9script', 'let var= 234'], 'E1004:')
|
||||
call CheckScriptFailure(['vim9script', 'let var = 234', 'var+=234'], 'E1004:')
|
||||
call CheckScriptFailure(['vim9script', 'let var = 234', 'var+=234'], "before and after '+='")
|
||||
call CheckScriptFailure(['vim9script', 'let var = "x"', 'var..="y"'], 'E1004:')
|
||||
call CheckScriptFailure(['vim9script', 'let var = "x"', 'var..="y"'], "before and after '..='")
|
||||
CheckScriptFailure(['vim9script', 'let var=234'], 'E1004:')
|
||||
CheckScriptFailure(['vim9script', 'let var=234'], "before and after '='")
|
||||
CheckScriptFailure(['vim9script', 'let var =234'], 'E1004:')
|
||||
CheckScriptFailure(['vim9script', 'let var= 234'], 'E1004:')
|
||||
CheckScriptFailure(['vim9script', 'let var = 234', 'var+=234'], 'E1004:')
|
||||
CheckScriptFailure(['vim9script', 'let var = 234', 'var+=234'], "before and after '+='")
|
||||
CheckScriptFailure(['vim9script', 'let var = "x"', 'var..="y"'], 'E1004:')
|
||||
CheckScriptFailure(['vim9script', 'let var = "x"', 'var..="y"'], "before and after '..='")
|
||||
|
||||
call CheckDefFailure(['let true = 1'], 'E1034:')
|
||||
call CheckDefFailure(['let false = 1'], 'E1034:')
|
||||
CheckDefFailure(['let true = 1'], 'E1034:')
|
||||
CheckDefFailure(['let false = 1'], 'E1034:')
|
||||
|
||||
call CheckDefFailure(['[a; b; c] = g:list'], 'E452:')
|
||||
call CheckDefExecFailure(['let a: number',
|
||||
'[a] = test_null_list()'], 'E1093:')
|
||||
call CheckDefExecFailure(['let a: number',
|
||||
'[a] = []'], 'E1093:')
|
||||
call CheckDefExecFailure(['let x: number',
|
||||
'let y: number',
|
||||
'[x, y] = [1]'], 'E1093:')
|
||||
call CheckDefExecFailure(['let x: number',
|
||||
'let y: number',
|
||||
'let z: list<number>',
|
||||
'[x, y; z] = [1]'], 'E1093:')
|
||||
CheckDefFailure(['[a; b; c] = g:list'], 'E452:')
|
||||
CheckDefExecFailure(['let a: number',
|
||||
'[a] = test_null_list()'], 'E1093:')
|
||||
CheckDefExecFailure(['let a: number',
|
||||
'[a] = []'], 'E1093:')
|
||||
CheckDefExecFailure(['let x: number',
|
||||
'let y: number',
|
||||
'[x, y] = [1]'], 'E1093:')
|
||||
CheckDefExecFailure(['let x: number',
|
||||
'let y: number',
|
||||
'let z: list<number>',
|
||||
'[x, y; z] = [1]'], 'E1093:')
|
||||
|
||||
call CheckDefFailure(['let somevar'], "E1022:")
|
||||
call CheckDefFailure(['let &tabstop = 4'], 'E1052:')
|
||||
call CheckDefFailure(['&g:option = 5'], 'E113:')
|
||||
call CheckScriptFailure(['vim9script', 'let &tabstop = 4'], 'E1052:')
|
||||
CheckDefFailure(['let somevar'], "E1022:")
|
||||
CheckDefFailure(['let &tabstop = 4'], 'E1052:')
|
||||
CheckDefFailure(['&g:option = 5'], 'E113:')
|
||||
CheckScriptFailure(['vim9script', 'let &tabstop = 4'], 'E1052:')
|
||||
|
||||
call CheckDefFailure(['let $VAR = 5'], 'E1016: Cannot declare an environment variable:')
|
||||
call CheckScriptFailure(['vim9script', 'let $ENV = "xxx"'], 'E1016:')
|
||||
CheckDefFailure(['let $VAR = 5'], 'E1016: Cannot declare an environment variable:')
|
||||
CheckScriptFailure(['vim9script', 'let $ENV = "xxx"'], 'E1016:')
|
||||
|
||||
if has('dnd')
|
||||
call CheckDefFailure(['let @~ = 5'], 'E1066:')
|
||||
CheckDefFailure(['let @~ = 5'], 'E1066:')
|
||||
else
|
||||
call CheckDefFailure(['let @~ = 5'], 'E354:')
|
||||
call CheckDefFailure(['@~ = 5'], 'E354:')
|
||||
CheckDefFailure(['let @~ = 5'], 'E354:')
|
||||
CheckDefFailure(['@~ = 5'], 'E354:')
|
||||
endif
|
||||
call CheckDefFailure(['let @a = 5'], 'E1066:')
|
||||
call CheckDefFailure(['let @/ = "x"'], 'E1066:')
|
||||
call CheckScriptFailure(['vim9script', 'let @a = "abc"'], 'E1066:')
|
||||
CheckDefFailure(['let @a = 5'], 'E1066:')
|
||||
CheckDefFailure(['let @/ = "x"'], 'E1066:')
|
||||
CheckScriptFailure(['vim9script', 'let @a = "abc"'], 'E1066:')
|
||||
|
||||
call CheckDefFailure(['let g:var = 5'], 'E1016: Cannot declare a global variable:')
|
||||
call CheckDefFailure(['let w:var = 5'], 'E1016: Cannot declare a window variable:')
|
||||
call CheckDefFailure(['let b:var = 5'], 'E1016: Cannot declare a buffer variable:')
|
||||
call CheckDefFailure(['let t:var = 5'], 'E1016: Cannot declare a tab variable:')
|
||||
CheckDefFailure(['let g:var = 5'], 'E1016: Cannot declare a global variable:')
|
||||
CheckDefFailure(['let w:var = 5'], 'E1016: Cannot declare a window variable:')
|
||||
CheckDefFailure(['let b:var = 5'], 'E1016: Cannot declare a buffer variable:')
|
||||
CheckDefFailure(['let t:var = 5'], 'E1016: Cannot declare a tab variable:')
|
||||
|
||||
call CheckDefFailure(['let anr = 4', 'anr ..= "text"'], 'E1019:')
|
||||
call CheckDefFailure(['let xnr += 4'], 'E1020:', 1)
|
||||
call CheckScriptFailure(['vim9script', 'let xnr += 4'], 'E1020:')
|
||||
call CheckDefFailure(["let xnr = xnr + 1"], 'E1001:', 1)
|
||||
call CheckScriptFailure(['vim9script', 'let xnr = xnr + 4'], 'E121:')
|
||||
CheckDefFailure(['let anr = 4', 'anr ..= "text"'], 'E1019:')
|
||||
CheckDefFailure(['let xnr += 4'], 'E1020:', 1)
|
||||
CheckScriptFailure(['vim9script', 'let xnr += 4'], 'E1020:')
|
||||
CheckDefFailure(["let xnr = xnr + 1"], 'E1001:', 1)
|
||||
CheckScriptFailure(['vim9script', 'let xnr = xnr + 4'], 'E121:')
|
||||
|
||||
call CheckScriptFailure(['vim9script', 'def Func()', 'let dummy = s:notfound', 'enddef', 'defcompile'], 'E1108:')
|
||||
CheckScriptFailure(['vim9script', 'def Func()', 'let dummy = s:notfound', 'enddef', 'defcompile'], 'E1108:')
|
||||
|
||||
call CheckDefFailure(['let var: list<string> = [123]'], 'expected list<string> but got list<number>')
|
||||
call CheckDefFailure(['let var: list<number> = ["xx"]'], 'expected list<number> but got list<string>')
|
||||
CheckDefFailure(['let var: list<string> = [123]'], 'expected list<string> but got list<number>')
|
||||
CheckDefFailure(['let var: list<number> = ["xx"]'], 'expected list<number> but got list<string>')
|
||||
|
||||
call CheckDefFailure(['let var: dict<string> = #{key: 123}'], 'expected dict<string> but got dict<number>')
|
||||
call CheckDefFailure(['let var: dict<number> = #{key: "xx"}'], 'expected dict<number> but got dict<string>')
|
||||
CheckDefFailure(['let var: dict<string> = #{key: 123}'], 'expected dict<string> but got dict<number>')
|
||||
CheckDefFailure(['let var: dict<number> = #{key: "xx"}'], 'expected dict<number> but got dict<string>')
|
||||
|
||||
call CheckDefFailure(['let var = feedkeys("0")'], 'E1031:')
|
||||
call CheckDefFailure(['let var: number = feedkeys("0")'], 'expected number but got void')
|
||||
CheckDefFailure(['let var = feedkeys("0")'], 'E1031:')
|
||||
CheckDefFailure(['let var: number = feedkeys("0")'], 'expected number but got void')
|
||||
|
||||
call CheckDefFailure(['let var: dict <number>'], 'E1068:')
|
||||
call CheckDefFailure(['let var: dict<number'], 'E1009:')
|
||||
CheckDefFailure(['let var: dict <number>'], 'E1068:')
|
||||
CheckDefFailure(['let var: dict<number'], 'E1009:')
|
||||
|
||||
call assert_fails('s/^/\=Mess()/n', 'E794:')
|
||||
call CheckDefFailure(['let var: dict<number'], 'E1009:')
|
||||
assert_fails('s/^/\=Mess()/n', 'E794:')
|
||||
CheckDefFailure(['let var: dict<number'], 'E1009:')
|
||||
|
||||
call CheckDefFailure(['w:foo: number = 10'],
|
||||
'E488: Trailing characters: : number = 1')
|
||||
call CheckDefFailure(['t:foo: bool = true'],
|
||||
'E488: Trailing characters: : bool = true')
|
||||
call CheckDefFailure(['b:foo: string = "x"'],
|
||||
'E488: Trailing characters: : string = "x"')
|
||||
call CheckDefFailure(['g:foo: number = 123'],
|
||||
'E488: Trailing characters: : number = 123')
|
||||
CheckDefFailure(['w:foo: number = 10'],
|
||||
'E488: Trailing characters: : number = 1')
|
||||
CheckDefFailure(['t:foo: bool = true'],
|
||||
'E488: Trailing characters: : bool = true')
|
||||
CheckDefFailure(['b:foo: string = "x"'],
|
||||
'E488: Trailing characters: : string = "x"')
|
||||
CheckDefFailure(['g:foo: number = 123'],
|
||||
'E488: Trailing characters: : number = 123')
|
||||
enddef
|
||||
|
||||
def Test_unlet()
|
||||
@@ -633,32 +633,32 @@ def Test_unlet()
|
||||
assert_false(exists('s:somevar'))
|
||||
unlet! s:somevar
|
||||
|
||||
call CheckScriptFailure([
|
||||
'vim9script',
|
||||
'let svar = 123',
|
||||
'unlet svar',
|
||||
], 'E1081:')
|
||||
call CheckScriptFailure([
|
||||
'vim9script',
|
||||
'let svar = 123',
|
||||
'unlet s:svar',
|
||||
], 'E1081:')
|
||||
call CheckScriptFailure([
|
||||
'vim9script',
|
||||
'let svar = 123',
|
||||
'def Func()',
|
||||
' unlet svar',
|
||||
'enddef',
|
||||
'defcompile',
|
||||
], 'E1081:')
|
||||
call CheckScriptFailure([
|
||||
'vim9script',
|
||||
'let svar = 123',
|
||||
'def Func()',
|
||||
' unlet s:svar',
|
||||
'enddef',
|
||||
'defcompile',
|
||||
], 'E1081:')
|
||||
CheckScriptFailure([
|
||||
'vim9script',
|
||||
'let svar = 123',
|
||||
'unlet svar',
|
||||
], 'E1081:')
|
||||
CheckScriptFailure([
|
||||
'vim9script',
|
||||
'let svar = 123',
|
||||
'unlet s:svar',
|
||||
], 'E1081:')
|
||||
CheckScriptFailure([
|
||||
'vim9script',
|
||||
'let svar = 123',
|
||||
'def Func()',
|
||||
' unlet svar',
|
||||
'enddef',
|
||||
'defcompile',
|
||||
], 'E1081:')
|
||||
CheckScriptFailure([
|
||||
'vim9script',
|
||||
'let svar = 123',
|
||||
'def Func()',
|
||||
' unlet s:svar',
|
||||
'enddef',
|
||||
'defcompile',
|
||||
], 'E1081:')
|
||||
|
||||
$ENVVAR = 'foobar'
|
||||
assert_equal('foobar', $ENVVAR)
|
||||
@@ -790,10 +790,10 @@ func Test_const()
|
||||
endfunc
|
||||
|
||||
def Test_range_no_colon()
|
||||
call CheckDefFailure(['%s/a/b/'], 'E1050:')
|
||||
call CheckDefFailure(['+ s/a/b/'], 'E1050:')
|
||||
call CheckDefFailure(['- s/a/b/'], 'E1050:')
|
||||
call CheckDefFailure(['. s/a/b/'], 'E1050:')
|
||||
CheckDefFailure(['%s/a/b/'], 'E1050:')
|
||||
CheckDefFailure(['+ s/a/b/'], 'E1050:')
|
||||
CheckDefFailure(['- s/a/b/'], 'E1050:')
|
||||
CheckDefFailure(['. s/a/b/'], 'E1050:')
|
||||
enddef
|
||||
|
||||
|
||||
@@ -1087,19 +1087,19 @@ def Test_try_catch_match()
|
||||
enddef
|
||||
|
||||
def Test_try_catch_fails()
|
||||
call CheckDefFailure(['catch'], 'E603:')
|
||||
call CheckDefFailure(['try', 'echo 0', 'catch', 'catch'], 'E1033:')
|
||||
call CheckDefFailure(['try', 'echo 0', 'catch /pat'], 'E1067:')
|
||||
call CheckDefFailure(['finally'], 'E606:')
|
||||
call CheckDefFailure(['try', 'echo 0', 'finally', 'echo 1', 'finally'], 'E607:')
|
||||
call CheckDefFailure(['endtry'], 'E602:')
|
||||
call CheckDefFailure(['while 1', 'endtry'], 'E170:')
|
||||
call CheckDefFailure(['for i in range(5)', 'endtry'], 'E170:')
|
||||
call CheckDefFailure(['if 2', 'endtry'], 'E171:')
|
||||
call CheckDefFailure(['try', 'echo 1', 'endtry'], 'E1032:')
|
||||
CheckDefFailure(['catch'], 'E603:')
|
||||
CheckDefFailure(['try', 'echo 0', 'catch', 'catch'], 'E1033:')
|
||||
CheckDefFailure(['try', 'echo 0', 'catch /pat'], 'E1067:')
|
||||
CheckDefFailure(['finally'], 'E606:')
|
||||
CheckDefFailure(['try', 'echo 0', 'finally', 'echo 1', 'finally'], 'E607:')
|
||||
CheckDefFailure(['endtry'], 'E602:')
|
||||
CheckDefFailure(['while 1', 'endtry'], 'E170:')
|
||||
CheckDefFailure(['for i in range(5)', 'endtry'], 'E170:')
|
||||
CheckDefFailure(['if 2', 'endtry'], 'E171:')
|
||||
CheckDefFailure(['try', 'echo 1', 'endtry'], 'E1032:')
|
||||
|
||||
call CheckDefFailure(['throw'], 'E1015:')
|
||||
call CheckDefFailure(['throw xxx'], 'E1001:')
|
||||
CheckDefFailure(['throw'], 'E1015:')
|
||||
CheckDefFailure(['throw xxx'], 'E1001:')
|
||||
enddef
|
||||
|
||||
def Test_throw_vimscript()
|
||||
@@ -1745,7 +1745,7 @@ def Test_vim9script_reload_delfunc()
|
||||
let nono_lines =<< trim END
|
||||
def g:DoCheck(no_exists: bool)
|
||||
assert_equal('yes', FuncYes())
|
||||
assert_fails('call FuncNo()', 'E117:')
|
||||
assert_fails('FuncNo()', 'E117:')
|
||||
enddef
|
||||
END
|
||||
|
||||
@@ -1972,11 +1972,11 @@ def Test_fixed_size_list()
|
||||
enddef
|
||||
|
||||
def Test_no_insert_xit()
|
||||
call CheckDefExecFailure(['a = 1'], 'E1100:')
|
||||
call CheckDefExecFailure(['c = 1'], 'E1100:')
|
||||
call CheckDefExecFailure(['i = 1'], 'E1100:')
|
||||
call CheckDefExecFailure(['t = 1'], 'E1100:')
|
||||
call CheckDefExecFailure(['x = 1'], 'E1100:')
|
||||
CheckDefExecFailure(['a = 1'], 'E1100:')
|
||||
CheckDefExecFailure(['c = 1'], 'E1100:')
|
||||
CheckDefExecFailure(['i = 1'], 'E1100:')
|
||||
CheckDefExecFailure(['t = 1'], 'E1100:')
|
||||
CheckDefExecFailure(['x = 1'], 'E1100:')
|
||||
|
||||
CheckScriptFailure(['vim9script', 'a = 1'], 'E488:')
|
||||
CheckScriptFailure(['vim9script', 'a'], 'E1100:')
|
||||
@@ -2008,11 +2008,11 @@ def Test_if_elseif_else()
|
||||
enddef
|
||||
|
||||
def Test_if_elseif_else_fails()
|
||||
call CheckDefFailure(['elseif true'], 'E582:')
|
||||
call CheckDefFailure(['else'], 'E581:')
|
||||
call CheckDefFailure(['endif'], 'E580:')
|
||||
call CheckDefFailure(['if true', 'elseif xxx'], 'E1001:')
|
||||
call CheckDefFailure(['if true', 'echo 1'], 'E171:')
|
||||
CheckDefFailure(['elseif true'], 'E582:')
|
||||
CheckDefFailure(['else'], 'E581:')
|
||||
CheckDefFailure(['endif'], 'E580:')
|
||||
CheckDefFailure(['if true', 'elseif xxx'], 'E1001:')
|
||||
CheckDefFailure(['if true', 'echo 1'], 'E171:')
|
||||
enddef
|
||||
|
||||
let g:bool_true = v:true
|
||||
@@ -2141,10 +2141,10 @@ def Test_if_const_expr()
|
||||
enddef
|
||||
|
||||
def Test_if_const_expr_fails()
|
||||
call CheckDefFailure(['if "aaa" == "bbb'], 'E114:')
|
||||
call CheckDefFailure(["if 'aaa' == 'bbb"], 'E115:')
|
||||
call CheckDefFailure(["if has('aaa'"], 'E110:')
|
||||
call CheckDefFailure(["if has('aaa') ? true false"], 'E109:')
|
||||
CheckDefFailure(['if "aaa" == "bbb'], 'E114:')
|
||||
CheckDefFailure(["if 'aaa' == 'bbb"], 'E115:')
|
||||
CheckDefFailure(["if has('aaa'"], 'E110:')
|
||||
CheckDefFailure(["if has('aaa') ? true false"], 'E109:')
|
||||
enddef
|
||||
|
||||
def RunNested(i: number): number
|
||||
@@ -2170,18 +2170,18 @@ enddef
|
||||
def Test_execute_cmd()
|
||||
new
|
||||
setline(1, 'default')
|
||||
execute 'call setline(1, "execute-string")'
|
||||
execute 'setline(1, "execute-string")'
|
||||
assert_equal('execute-string', getline(1))
|
||||
|
||||
execute "call setline(1, 'execute-string')"
|
||||
execute "setline(1, 'execute-string')"
|
||||
assert_equal('execute-string', getline(1))
|
||||
|
||||
let cmd1 = 'call setline(1,'
|
||||
let cmd1 = 'setline(1,'
|
||||
let cmd2 = '"execute-var")'
|
||||
execute cmd1 cmd2 # comment
|
||||
assert_equal('execute-var', getline(1))
|
||||
|
||||
execute cmd1 cmd2 '|call setline(1, "execute-var-string")'
|
||||
execute cmd1 cmd2 '|setline(1, "execute-var-string")'
|
||||
assert_equal('execute-var-string', getline(1))
|
||||
|
||||
let cmd_first = 'call '
|
||||
@@ -2197,9 +2197,9 @@ def Test_execute_cmd()
|
||||
echomsg [1, 2, 3] #{a: 1, b: 2}
|
||||
assert_match('^\[1, 2, 3\] {''a'': 1, ''b'': 2}$', Screenline(&lines))
|
||||
|
||||
call CheckDefFailure(['execute xxx'], 'E1001:', 1)
|
||||
call CheckDefExecFailure(['execute "tabnext " .. 8'], 'E475:', 1)
|
||||
call CheckDefFailure(['execute "cmd"# comment'], 'E488:', 1)
|
||||
CheckDefFailure(['execute xxx'], 'E1001:', 1)
|
||||
CheckDefExecFailure(['execute "tabnext " .. 8'], 'E475:', 1)
|
||||
CheckDefFailure(['execute "cmd"# comment'], 'E488:', 1)
|
||||
enddef
|
||||
|
||||
def Test_execute_cmd_vimscript()
|
||||
@@ -2229,7 +2229,7 @@ def Test_echo_cmd()
|
||||
echo str1 str2
|
||||
assert_match('^some more$', Screenline(&lines))
|
||||
|
||||
call CheckDefFailure(['echo "xxx"# comment'], 'E488:')
|
||||
CheckDefFailure(['echo "xxx"# comment'], 'E488:')
|
||||
enddef
|
||||
|
||||
def Test_echomsg_cmd()
|
||||
@@ -2239,7 +2239,7 @@ def Test_echomsg_cmd()
|
||||
:1messages
|
||||
assert_match('^some more$', Screenline(&lines))
|
||||
|
||||
call CheckDefFailure(['echomsg "xxx"# comment'], 'E488:')
|
||||
CheckDefFailure(['echomsg "xxx"# comment'], 'E488:')
|
||||
enddef
|
||||
|
||||
def Test_echomsg_cmd_vimscript()
|
||||
@@ -2922,7 +2922,7 @@ def Test_vim9_comment_not_compiled()
|
||||
CheckScriptSuccess([
|
||||
'vim9script',
|
||||
'new'
|
||||
'call setline(1, ["# define pat", "last"])',
|
||||
'setline(1, ["# define pat", "last"])',
|
||||
':$',
|
||||
'dsearch /pat/ #comment',
|
||||
'bwipe!',
|
||||
@@ -2931,7 +2931,7 @@ def Test_vim9_comment_not_compiled()
|
||||
CheckScriptFailure([
|
||||
'vim9script',
|
||||
'new'
|
||||
'call setline(1, ["# define pat", "last"])',
|
||||
'setline(1, ["# define pat", "last"])',
|
||||
':$',
|
||||
'dsearch /pat/#comment',
|
||||
'bwipe!',
|
||||
@@ -3266,7 +3266,7 @@ def Test_invalid_sid()
|
||||
assert_fails('func <SNR>1234_func', 'E123:')
|
||||
|
||||
if RunVim([], ['wq Xdidit'], '+"func <SNR>1_func"')
|
||||
call assert_equal([], readfile('Xdidit'))
|
||||
assert_equal([], readfile('Xdidit'))
|
||||
endif
|
||||
delete('Xdidit')
|
||||
enddef
|
||||
|
@@ -754,6 +754,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1623,
|
||||
/**/
|
||||
1622,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user