mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
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 #8245)
This commit is contained in:
committed by
Bram Moolenaar
parent
ad5c178a19
commit
611728f806
@@ -223,8 +223,28 @@ func Test_lockvar()
|
|||||||
call add(val, 4)
|
call add(val, 4)
|
||||||
call assert_equal([9, 2, 3, 4], val)
|
call assert_equal([9, 2, 3, 4], val)
|
||||||
call assert_fails('let val = [4, 5, 6]', 'E1122:')
|
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()
|
func Test_const_with_index_access()
|
||||||
let l = [1, 2, 3]
|
let l = [1, 2, 3]
|
||||||
|
@@ -1843,6 +1843,10 @@ func Test_func_exists_on_reload()
|
|||||||
call writefile(['func ExistingFunction()', 'echo "yes"', 'endfunc'], 'Xfuncexists2')
|
call writefile(['func ExistingFunction()', 'echo "yes"', 'endfunc'], 'Xfuncexists2')
|
||||||
call assert_fails('source Xfuncexists2', 'E122:')
|
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
|
delfunc ExistingFunction
|
||||||
call assert_equal(0, exists('*ExistingFunction'))
|
call assert_equal(0, exists('*ExistingFunction'))
|
||||||
call writefile([
|
call writefile([
|
||||||
|
@@ -314,6 +314,8 @@ func Test_python_window()
|
|||||||
10new
|
10new
|
||||||
py vim.current.window.height = 5
|
py vim.current.window.height = 5
|
||||||
call assert_equal(5, winheight(0))
|
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
|
" Test for setting the window width
|
||||||
10vnew
|
10vnew
|
||||||
|
@@ -511,6 +511,8 @@ func Test_python3_window()
|
|||||||
10new
|
10new
|
||||||
py3 vim.current.window.height = 5
|
py3 vim.current.window.height = 5
|
||||||
call assert_equal(5, winheight(0))
|
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
|
" Test for setting the window width
|
||||||
10vnew
|
10vnew
|
||||||
|
@@ -405,6 +405,7 @@ func Test_func_def_error()
|
|||||||
let l = join(lines, "\n") . "\n"
|
let l = join(lines, "\n") . "\n"
|
||||||
exe l
|
exe l
|
||||||
call assert_fails('exe l', 'E717:')
|
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
|
" Define an autoload function with an incorrect file name
|
||||||
call writefile(['func foo#Bar()', 'return 1', 'endfunc'], 'Xscript')
|
call writefile(['func foo#Bar()', 'return 1', 'endfunc'], 'Xscript')
|
||||||
@@ -420,6 +421,11 @@ func Test_del_func()
|
|||||||
call assert_fails('delfunction Xabc', 'E130:')
|
call assert_fails('delfunction Xabc', 'E130:')
|
||||||
let d = {'a' : 10}
|
let d = {'a' : 10}
|
||||||
call assert_fails('delfunc d.a', 'E718:')
|
call assert_fails('delfunc d.a', 'E718:')
|
||||||
|
func d.fn()
|
||||||
|
return 1
|
||||||
|
endfunc
|
||||||
|
delfunc d.fn
|
||||||
|
call assert_equal({'a' : 10}, d)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test for calling return outside of a function
|
" Test for calling return outside of a function
|
||||||
@@ -451,11 +457,12 @@ func Test_func_dict()
|
|||||||
return len(self)
|
return len(self)
|
||||||
endfunc
|
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_equal(2, mydict.somefunc())
|
||||||
call assert_match("^\n function \\d\\\+() dict"
|
call assert_match("^\n function \\d\\\+() dict"
|
||||||
\ .. "\n1 return len(self)"
|
\ .. "\n1 return len(self)"
|
||||||
\ .. "\n endfunction$", execute('func mydict.somefunc'))
|
\ .. "\n endfunction$", execute('func mydict.somefunc'))
|
||||||
|
call assert_fails('call mydict.nonexist()', 'E716:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_func_range()
|
func Test_func_range()
|
||||||
|
@@ -1941,6 +1941,9 @@ def Test_expr7_lambda()
|
|||||||
CheckDefAndScriptFailure(["var Ref = (a)=>a + 1"], 'E1004:')
|
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: White space required before and after ''=>'' at "=> a + 1"')
|
||||||
CheckDefAndScriptFailure(["var Ref = (a) =>a + 1"], 'E1004:')
|
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)
|
CheckDefAndScriptFailure(["filter([1, 2], (k,v) => 1)"], 'E1069:', 1)
|
||||||
# error is in first line of the lambda
|
# error is in first line of the lambda
|
||||||
|
@@ -887,6 +887,12 @@ def Test_lambda_return_type()
|
|||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E1157:', 1)
|
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
|
# this works
|
||||||
for x in ['foo', 'boo']
|
for x in ['foo', 'boo']
|
||||||
echo FilterWithCond(x, (v) => v =~ '^b')
|
echo FilterWithCond(x, (v) => v =~ '^b')
|
||||||
@@ -1318,6 +1324,7 @@ def Test_white_space_before_comma()
|
|||||||
enddef
|
enddef
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1068:')
|
CheckScriptFailure(lines, 'E1068:')
|
||||||
|
call assert_fails('vim9cmd echo stridx("a" .. "b" , "a")', 'E1068:')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_white_space_after_comma()
|
def Test_white_space_after_comma()
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2881,
|
||||||
/**/
|
/**/
|
||||||
2880,
|
2880,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user