summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2021-05-24 15:15:47 +0200
committerBram Moolenaar <Bram@vim.org>2021-05-24 15:15:47 +0200
commit611728f80604dd56960e8c197e5749d203c8feb1 (patch)
tree1c056b902cf1516372f1024f0fa1659cbc56e32a
parentad5c178a191cf2cf37a27c2a789d7afda3879831 (diff)
downloadvim-git-611728f80604dd56960e8c197e5749d203c8feb1.tar.gz
patch 8.2.2881: various pieces of code not covered by testsv8.2.2881
Problem: Various pieces of code not covered by tests. Solution: Add a few more tests. (Yegappan Lakshmanan, closes #8245)
-rw-r--r--src/testdir/test_const.vim22
-rw-r--r--src/testdir/test_functions.vim4
-rw-r--r--src/testdir/test_python2.vim2
-rw-r--r--src/testdir/test_python3.vim2
-rw-r--r--src/testdir/test_user_func.vim9
-rw-r--r--src/testdir/test_vim9_expr.vim3
-rw-r--r--src/testdir/test_vim9_func.vim7
-rw-r--r--src/version.c2
8 files changed, 49 insertions, 2 deletions
diff --git a/src/testdir/test_const.vim b/src/testdir/test_const.vim
index c88efa632..2b79f42fe 100644
--- a/src/testdir/test_const.vim
+++ b/src/testdir/test_const.vim
@@ -223,8 +223,28 @@ func Test_lockvar()
call add(val, 4)
call assert_equal([9, 2, 3, 4], val)
call assert_fails('let val = [4, 5, 6]', 'E1122:')
-endfunc
+ 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]
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index b4d462b86..dcc2b0486 100644
--- 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([
diff --git a/src/testdir/test_python2.vim b/src/testdir/test_python2.vim
index 84c917316..89afa2b5a 100644
--- 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
diff --git a/src/testdir/test_python3.vim b/src/testdir/test_python3.vim
index 1e9ef82b0..66d5db57f 100644
--- 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
diff --git a/src/testdir/test_user_func.vim b/src/testdir/test_user_func.vim
index a58aa64b9..4b8ec99a2 100644
--- 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()
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index fe5de29d0..4a67522cb 100644
--- 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
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index 7eca70919..2ac97d0f4 100644
--- 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()
diff --git a/src/version.c b/src/version.c
index 1c4bbfada..7fb140112 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2881,
+/**/
2880,
/**/
2879,