Mercurial > vim
changeset 24685:04205b7d67d5 v8.2.2881
patch 8.2.2881: various pieces of code not covered by tests
Commit: https://github.com/vim/vim/commit/611728f80604dd56960e8c197e5749d203c8feb1
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Mon May 24 15:15:47 2021 +0200
patch 8.2.2881: various pieces of code not covered by tests
Problem: Various pieces of code not covered by tests.
Solution: Add a few more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/8245)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 24 May 2021 15:30:03 +0200 |
parents | 1706f44ede8e |
children | b839c305dfa6 |
files | src/testdir/test_const.vim src/testdir/test_functions.vim src/testdir/test_python2.vim src/testdir/test_python3.vim src/testdir/test_user_func.vim src/testdir/test_vim9_expr.vim src/testdir/test_vim9_func.vim src/version.c |
diffstat | 8 files changed, 49 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testdir/test_const.vim +++ b/src/testdir/test_const.vim @@ -223,9 +223,29 @@ func Test_lockvar() call add(val, 4) call assert_equal([9, 2, 3, 4], val) call assert_fails('let val = [4, 5, 6]', 'E1122:') + + let l =<< trim END + let d = {} + lockvar d + func d.fn() + return 1 + endfunc + END + let @a = l->join("\n") + call assert_fails('exe @a', 'E741:') + + let l =<< trim END + let d = {} + let d.fn = function("min") + lockvar d.fn + func! d.fn() + return 1 + endfunc + END + let @a = l->join("\n") + call assert_fails('exe @a', 'E741:') endfunc - func Test_const_with_index_access() let l = [1, 2, 3] call assert_fails('const l[0] = 4', 'E996:')
--- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -1843,6 +1843,10 @@ func Test_func_exists_on_reload() call writefile(['func ExistingFunction()', 'echo "yes"', 'endfunc'], 'Xfuncexists2') call assert_fails('source Xfuncexists2', 'E122:') + " Defining a new function from the cmdline should fail if the function is + " already defined + call assert_fails('call feedkeys(":func ExistingFunction()\<CR>", "xt")', 'E122:') + delfunc ExistingFunction call assert_equal(0, exists('*ExistingFunction')) call writefile([
--- a/src/testdir/test_python2.vim +++ b/src/testdir/test_python2.vim @@ -314,6 +314,8 @@ func Test_python_window() 10new py vim.current.window.height = 5 call assert_equal(5, winheight(0)) + py vim.current.window.height = 3.2 + call assert_equal(3, winheight(0)) " Test for setting the window width 10vnew
--- a/src/testdir/test_python3.vim +++ b/src/testdir/test_python3.vim @@ -511,6 +511,8 @@ func Test_python3_window() 10new py3 vim.current.window.height = 5 call assert_equal(5, winheight(0)) + py3 vim.current.window.height = 3.2 + call assert_equal(3, winheight(0)) " Test for setting the window width 10vnew
--- a/src/testdir/test_user_func.vim +++ b/src/testdir/test_user_func.vim @@ -405,6 +405,7 @@ func Test_func_def_error() let l = join(lines, "\n") . "\n" exe l call assert_fails('exe l', 'E717:') + call assert_fails('call feedkeys(":func d.F1()\<CR>", "xt")', 'E717:') " Define an autoload function with an incorrect file name call writefile(['func foo#Bar()', 'return 1', 'endfunc'], 'Xscript') @@ -420,6 +421,11 @@ func Test_del_func() call assert_fails('delfunction Xabc', 'E130:') let d = {'a' : 10} call assert_fails('delfunc d.a', 'E718:') + func d.fn() + return 1 + endfunc + delfunc d.fn + call assert_equal({'a' : 10}, d) endfunc " Test for calling return outside of a function @@ -451,11 +457,12 @@ func Test_func_dict() return len(self) endfunc - call assert_equal("{'a': 'b', 'somefunc': function('2')}", string(mydict)) + call assert_equal("{'a': 'b', 'somefunc': function('3')}", string(mydict)) call assert_equal(2, mydict.somefunc()) call assert_match("^\n function \\d\\\+() dict" \ .. "\n1 return len(self)" \ .. "\n endfunction$", execute('func mydict.somefunc')) + call assert_fails('call mydict.nonexist()', 'E716:') endfunc func Test_func_range()
--- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -1941,6 +1941,9 @@ 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: int) => a + 1"], 'E1010:') + CheckDefAndScriptFailure(["var Ref = (a): int => a + 1"], 'E1010:') CheckDefAndScriptFailure(["filter([1, 2], (k,v) => 1)"], 'E1069:', 1) # error is in first line of the lambda
--- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -887,6 +887,12 @@ def Test_lambda_return_type() END CheckDefAndScriptFailure(lines, 'E1157:', 1) + # no space before the return type + lines =<< trim END + var Ref = (x):number => x + 1 + END + CheckDefAndScriptFailure(lines, 'E1069:', 1) + # this works for x in ['foo', 'boo'] echo FilterWithCond(x, (v) => v =~ '^b') @@ -1318,6 +1324,7 @@ def Test_white_space_before_comma() enddef END CheckScriptFailure(lines, 'E1068:') + call assert_fails('vim9cmd echo stridx("a" .. "b" , "a")', 'E1068:') enddef def Test_white_space_after_comma()