diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2021-05-25 20:14:00 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-05-25 20:14:00 +0200 |
commit | 34fcb697240c1bc9e69417ed75db3b1a83479724 (patch) | |
tree | aaad1ed8d12bdcd32bf178eac8c7a17259bb529a | |
parent | 872bee557e5f8ab0e4a523a6a845868a2801b17e (diff) |
patch 8.2.2886: various pieces of code not covered by testsv8.2.2886
Problem: Various pieces of code not covered by tests.
Solution: Add a few more tests. (Yegappan Lakshmanan, closes #8255)
-rw-r--r-- | src/testdir/test_expr.vim | 1 | ||||
-rw-r--r-- | src/testdir/test_functions.vim | 7 | ||||
-rw-r--r-- | src/testdir/test_listdict.vim | 5 | ||||
-rw-r--r-- | src/testdir/test_registers.vim | 9 | ||||
-rw-r--r-- | src/testdir/test_user_func.vim | 10 | ||||
-rw-r--r-- | src/testdir/test_vim9_builtin.vim | 8 | ||||
-rw-r--r-- | src/testdir/test_vim9_expr.vim | 3 | ||||
-rw-r--r-- | src/testdir/test_vim9_func.vim | 8 | ||||
-rw-r--r-- | src/version.c | 2 |
9 files changed, 53 insertions, 0 deletions
diff --git a/src/testdir/test_expr.vim b/src/testdir/test_expr.vim index dde6e77ba7..597c022145 100644 --- a/src/testdir/test_expr.vim +++ b/src/testdir/test_expr.vim @@ -127,6 +127,7 @@ func Test_getreg_empty_list() let y = x call add(x, 'foo') call assert_equal(['foo'], y) + call assert_fails('call getreg([])', 'E730:') endfunc func Test_loop_over_null_list() diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim index dcc2b04863..4337606584 100644 --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -141,6 +141,7 @@ func Test_min() call assert_fails('call min(1)', 'E712:') call assert_fails('call min(v:none)', 'E712:') + call assert_fails('call min([1, {}])', 'E728:') " check we only get one error call assert_fails('call min([[1], #{}])', ['E745:', 'E745:']) @@ -715,6 +716,7 @@ func Test_tr() call assert_fails("let s=tr('abcd', 'abcd', 'def')", 'E475:') call assert_equal('hEllO', tr('hello', 'eo', 'EO')) call assert_equal('hello', tr('hello', 'xy', 'ab')) + call assert_fails('call tr("abc", "123", "₁₂")', 'E475:') set encoding=utf8 endfunc @@ -2674,4 +2676,9 @@ func Test_default_arg_value() call assert_equal('msg', HasDefault()) endfunc +" Test for gettext() +func Test_gettext() + call assert_fails('call gettext(1)', 'E475:') +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_listdict.vim b/src/testdir/test_listdict.vim index 601dd17e5e..46b030b86e 100644 --- a/src/testdir/test_listdict.vim +++ b/src/testdir/test_listdict.vim @@ -513,6 +513,11 @@ func Test_list_locked_var_unlet() call assert_equal(expected[depth][u][1], ps) endfor endfor + " Deleting a list range should fail if the range is locked + let l = [1, 2, 3, 4] + lockvar l[1:2] + call assert_fails('unlet l[1:2]', 'E741:') + unlet l endfunc " Locked variables and :unlet or list / dict functions diff --git a/src/testdir/test_registers.vim b/src/testdir/test_registers.vim index c10af29466..58f5191114 100644 --- a/src/testdir/test_registers.vim +++ b/src/testdir/test_registers.vim @@ -281,6 +281,7 @@ endfunc func Test_set_register() call assert_fails("call setreg('#', 200)", 'E86:') + call assert_fails("call setreg('a', test_unknown())", 'E908:') edit Xfile_alt_1 let b1 = bufnr('') @@ -470,6 +471,14 @@ func Test_get_reginfo() let info = getreginfo('"') call assert_equal('z', info.points_to) + let @a="a1b2" + nnoremap <F2> <Cmd>let g:RegInfo = getreginfo()<CR> + exe "normal \"a\<F2>" + call assert_equal({'regcontents': ['a1b2'], 'isunnamed': v:false, + \ 'regtype': 'v'}, g:RegInfo) + nunmap <F2> + unlet g:RegInfo + bwipe! endfunc diff --git a/src/testdir/test_user_func.vim b/src/testdir/test_user_func.vim index 4b8ec99a2b..747ec486bc 100644 --- a/src/testdir/test_user_func.vim +++ b/src/testdir/test_user_func.vim @@ -160,6 +160,16 @@ func Test_default_arg() \ .. "1 return deepcopy(a:)\n" \ .. " endfunction", \ execute('func Args2')) + + " Error in default argument expression + let l =<< trim END + func F1(x = y) + return a:x * 2 + endfunc + echo F1() + END + let @a = l->join("\n") + call assert_fails("exe @a", 'E121:') endfunc func s:addFoo(lead) diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index c6df6fea18..8f0d47f569 100644 --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -363,6 +363,7 @@ def Test_extend_arg_types() END CheckDefAndScriptSuccess(lines) + CheckDefFailure(['extend("a", 1)'], 'E1013: Argument 1: type mismatch, expected list<any> but got string') CheckDefFailure(['extend([1, 2], 3)'], 'E1013: Argument 2: type mismatch, expected list<number> but got number') CheckDefFailure(['extend([1, 2], ["x"])'], 'E1013: Argument 2: type mismatch, expected list<number> but got list<string>') CheckDefFailure(['extend([1, 2], [3], "x")'], 'E1013: Argument 3: type mismatch, expected number but got string') @@ -726,6 +727,12 @@ def Test_insert() endfor res->assert_equal(6) + var m: any = [] + insert(m, 4) + call assert_equal([4], m) + extend(m, [6], 0) + call assert_equal([6, 4], m) + var lines =<< trim END insert(test_null_list(), 123) END @@ -743,6 +750,7 @@ def Test_insert() assert_equal(['a', 'b', 'c'], insert(['b', 'c'], 'a')) assert_equal(0z1234, insert(0z34, 0x12)) + CheckDefFailure(['insert("a", 1)'], 'E1013: Argument 1: type mismatch, expected list<any> but got string', 1) CheckDefFailure(['insert([2, 3], "a")'], 'E1013: Argument 2: type mismatch, expected number but got string', 1) CheckDefFailure(['insert([2, 3], 1, "x")'], 'E1013: Argument 3: type mismatch, expected number but got string', 1) enddef diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim index 4a67522cb6..3ca1f342cc 100644 --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -1580,6 +1580,8 @@ def Test_expr7t() var ln: list<number> = [<number>g:anint, <number>g:thefour] var nr = <number>234 assert_equal(234, nr) + var b: bool = <bool>1 + assert_equal(true, b) var text = <string> 'text' @@ -1591,6 +1593,7 @@ def Test_expr7t() CheckDefAndScriptFailure(["var x = <nr>123"], 'E1010:', 1) CheckDefFailure(["var x = <number>"], 'E1097:', 3) + CheckDefFailure(["var x = <number>string(1)"], 'E1012:', 1) CheckScriptFailure(['vim9script', "var x = <number>"], 'E15:', 2) CheckDefAndScriptFailure(["var x = <number >123"], 'E1068:', 1) CheckDefAndScriptFailure(["var x = <number 123"], 'E1104:', 1) diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index 2ac97d0f46..3626cca47a 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -397,6 +397,7 @@ def Test_call_default_args() delfunc g:Func CheckScriptFailure(['def Func(arg: number = "text")', 'enddef', 'defcompile'], 'E1013: Argument 1: type mismatch, expected number but got string') delfunc g:Func + CheckDefFailure(['def Func(x: number = )', 'enddef'], 'E15:') lines =<< trim END vim9script @@ -1315,6 +1316,8 @@ def Test_arg_type_wrong() CheckScriptFailure(['def Func4(...)', 'echo "a"', 'enddef'], 'E1055: Missing name after ...') CheckScriptFailure(['def Func5(items:string)', 'echo "a"'], 'E1069:') CheckScriptFailure(['def Func5(items)', 'echo "a"'], 'E1077:') + CheckScriptFailure(['def Func6(...x:list<number>)', 'echo "a"', 'enddef'], 'E1069:') + CheckScriptFailure(['def Func7(...x: int)', 'echo "a"', 'enddef'], 'E1010:') enddef def Test_white_space_before_comma() @@ -2717,6 +2720,11 @@ def Test_ignored_argument() var _ = 1 END CheckDefAndScriptFailure(lines, 'E1181:', 1) + + lines =<< trim END + var x = _ + END + CheckDefAndScriptFailure(lines, 'E1181:', 1) enddef def Test_too_many_arguments() diff --git a/src/version.c b/src/version.c index c841e6b501..4eced11fdb 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 */ /**/ + 2886, +/**/ 2885, /**/ 2884, |