diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-09-06 15:58:36 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-09-06 15:58:36 +0200 |
commit | d2c617055ac8ff6ff244f69e23dce1f73741c5ad (patch) | |
tree | a4c06018d3dd17046f21d0e6a0e9854c5e748f07 /src/testdir/test_vim9_script.vim | |
parent | 2f3cd2e4ec5617e3697ec4f4c6e1c9449061ad30 (diff) |
patch 8.2.1623: Vim9: using :call where it is not neededv8.2.1623
Problem: Vim9: using :call where it is not needed.
Solution: Remove :call. (closes #6892)
Diffstat (limited to 'src/testdir/test_vim9_script.vim')
-rw-r--r-- | src/testdir/test_vim9_script.vim | 310 |
1 files changed, 155 insertions, 155 deletions
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index ed7648efd3..a4fb8c7cd5 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -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:') - - 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 '..='") - - call CheckDefFailure(['let true = 1'], 'E1034:') - call 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:') - - call CheckDefFailure(['let somevar'], "E1022:") - call CheckDefFailure(['let &tabstop = 4'], 'E1052:') - call CheckDefFailure(['&g:option = 5'], 'E113:') - call 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=234'], 'E1004:') + CheckDefFailure(['let var =234'], 'E1004:') + CheckDefFailure(['let var= 234'], 'E1004:') + + 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 '..='") + + CheckDefFailure(['let true = 1'], 'E1034:') + CheckDefFailure(['let false = 1'], 'E1034:') + + 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:') + + CheckDefFailure(['let somevar'], "E1022:") + CheckDefFailure(['let &tabstop = 4'], 'E1052:') + CheckDefFailure(['&g:option = 5'], 'E113:') + CheckScriptFailure(['vim9script', 'let &tabstop = 4'], 'E1052:') + + 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 |