mirror of
https://github.com/neovim/neovim.git
synced 2024-12-29 14:41:06 -07:00
vim-patch:9.0.0335: checks for Dictionary argument often give a vague error (#23309)
Problem: Checks for Dictionary argument often give a vague error message.
Solution: Give a useful error message. (Yegappan Lakshmanan, closes vim/vim#11009)
04c4c5746e
Cherry-pick removal of E922 from docs from patch 9.0.1403.
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
parent
2e8410b7be
commit
43c49746d9
@ -2525,7 +2525,7 @@ funcref({name} [, {arglist}] [, {dict}])
|
||||
Can also be used as a |method|: >
|
||||
GetFuncname()->funcref([arg])
|
||||
<
|
||||
*function()* *partial* *E700* *E922* *E923*
|
||||
*function()* *partial* *E700* *E923*
|
||||
function({name} [, {arglist}] [, {dict}])
|
||||
Return a |Funcref| variable that refers to function {name}.
|
||||
{name} can be the name of a user defined function or an
|
||||
|
@ -5357,8 +5357,7 @@ void common_function(typval_T *argvars, typval_T *rettv, bool is_funcref)
|
||||
arg_idx = 1;
|
||||
}
|
||||
if (dict_idx > 0) {
|
||||
if (argvars[dict_idx].v_type != VAR_DICT) {
|
||||
emsg(_("E922: expected a dict"));
|
||||
if (tv_check_for_dict_arg(argvars, dict_idx) == FAIL) {
|
||||
xfree(name);
|
||||
goto theend;
|
||||
}
|
||||
@ -8726,7 +8725,7 @@ int typval_compare(typval_T *typ1, typval_T *typ2, exprtype_T type, bool ic)
|
||||
const bool type_is = type == EXPR_IS || type == EXPR_ISNOT;
|
||||
|
||||
if (type_is && typ1->v_type != typ2->v_type) {
|
||||
// For "is" a different type always means false, for "notis"
|
||||
// For "is" a different type always means false, for "isnot"
|
||||
// it means true.
|
||||
n1 = type == EXPR_ISNOT;
|
||||
} else if (typ1->v_type == VAR_BLOB || typ2->v_type == VAR_BLOB) {
|
||||
|
@ -597,8 +597,7 @@ static void f_call(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
|
||||
dict_T *selfdict = NULL;
|
||||
if (argvars[2].v_type != VAR_UNKNOWN) {
|
||||
if (argvars[2].v_type != VAR_DICT) {
|
||||
emsg(_(e_dictreq));
|
||||
if (tv_check_for_dict_arg(argvars, 2) == FAIL) {
|
||||
if (owned) {
|
||||
func_unref(func);
|
||||
}
|
||||
@ -7359,8 +7358,7 @@ static void f_setcharpos(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
|
||||
static void f_setcharsearch(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
if (argvars[0].v_type != VAR_DICT) {
|
||||
emsg(_(e_dictreq));
|
||||
if (tv_check_for_dict_arg(argvars, 0) == FAIL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -7631,8 +7629,7 @@ static void f_settagstack(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
}
|
||||
|
||||
// second argument: dict with items to set in the tag stack
|
||||
if (argvars[1].v_type != VAR_DICT) {
|
||||
emsg(_(e_dictreq));
|
||||
if (tv_check_for_dict_arg(argvars, 1) == FAIL) {
|
||||
return;
|
||||
}
|
||||
dict_T *d = argvars[1].vval.v_dict;
|
||||
@ -8987,11 +8984,10 @@ static void f_timer_start(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
}
|
||||
|
||||
if (argvars[2].v_type != VAR_UNKNOWN) {
|
||||
dict_T *dict = argvars[2].vval.v_dict;
|
||||
if (argvars[2].v_type != VAR_DICT || dict == NULL) {
|
||||
semsg(_(e_invarg2), tv_get_string(&argvars[2]));
|
||||
if (tv_check_for_nonnull_dict_arg(argvars, 2) == FAIL) {
|
||||
return;
|
||||
}
|
||||
dict_T *dict = argvars[2].vval.v_dict;
|
||||
dictitem_T *const di = tv_dict_find(dict, S_LEN("repeat"));
|
||||
if (di != NULL) {
|
||||
repeat = (int)tv_get_number(&di->di_tv);
|
||||
|
@ -60,6 +60,8 @@ static const char e_invalid_value_for_blob_nr[]
|
||||
= N_("E1239: Invalid value for blob: %d");
|
||||
static const char e_string_or_function_required_for_argument_nr[]
|
||||
= N_("E1256: String or function required for argument %d");
|
||||
static const char e_non_null_dict_required_for_argument_nr[]
|
||||
= N_("E1297: Non-NULL Dictionary required for argument %d");
|
||||
|
||||
bool tv_in_free_unref_items = false;
|
||||
|
||||
@ -1232,8 +1234,7 @@ static void do_sort_uniq(typval_T *argvars, typval_T *rettv, bool sort)
|
||||
|
||||
if (argvars[2].v_type != VAR_UNKNOWN) {
|
||||
// optional third argument: {dict}
|
||||
if (argvars[2].v_type != VAR_DICT) {
|
||||
emsg(_(e_dictreq));
|
||||
if (tv_check_for_dict_arg(argvars, 2) == FAIL) {
|
||||
goto theend;
|
||||
}
|
||||
info.item_compare_selfdict = argvars[2].vval.v_dict;
|
||||
@ -2993,10 +2994,10 @@ void f_values(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
/// "has_key()" function
|
||||
void f_has_key(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
if (argvars[0].v_type != VAR_DICT) {
|
||||
emsg(_(e_dictreq));
|
||||
if (tv_check_for_dict_arg(argvars, 0) == FAIL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (argvars[0].vval.v_dict == NULL) {
|
||||
return;
|
||||
}
|
||||
@ -4051,6 +4052,20 @@ int tv_check_for_dict_arg(const typval_T *const args, const int idx)
|
||||
return OK;
|
||||
}
|
||||
|
||||
/// Give an error and return FAIL unless "args[idx]" is a non-NULL dict.
|
||||
int tv_check_for_nonnull_dict_arg(const typval_T *const args, const int idx)
|
||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_PURE
|
||||
{
|
||||
if (tv_check_for_dict_arg(args, idx) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
if (args[idx].vval.v_dict == NULL) {
|
||||
semsg(_(e_non_null_dict_required_for_argument_nr), idx + 1);
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/// Check for an optional dict argument at "idx"
|
||||
int tv_check_for_opt_dict_arg(const typval_T *const args, const int idx)
|
||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_PURE
|
||||
|
@ -651,8 +651,7 @@ void f_win_splitmove(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
dict_T *d;
|
||||
dictitem_T *di;
|
||||
|
||||
if (argvars[2].v_type != VAR_DICT || argvars[2].vval.v_dict == NULL) {
|
||||
emsg(_(e_invarg));
|
||||
if (tv_check_for_nonnull_dict_arg(argvars, 2) == FAIL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -796,51 +795,50 @@ void f_winrestcmd(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
/// "winrestview()" function
|
||||
void f_winrestview(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
dict_T *dict = argvars[0].vval.v_dict;
|
||||
|
||||
if (argvars[0].v_type != VAR_DICT || dict == NULL) {
|
||||
emsg(_(e_invarg));
|
||||
} else {
|
||||
dictitem_T *di;
|
||||
if ((di = tv_dict_find(dict, S_LEN("lnum"))) != NULL) {
|
||||
curwin->w_cursor.lnum = (linenr_T)tv_get_number(&di->di_tv);
|
||||
}
|
||||
if ((di = tv_dict_find(dict, S_LEN("col"))) != NULL) {
|
||||
curwin->w_cursor.col = (colnr_T)tv_get_number(&di->di_tv);
|
||||
}
|
||||
if ((di = tv_dict_find(dict, S_LEN("coladd"))) != NULL) {
|
||||
curwin->w_cursor.coladd = (colnr_T)tv_get_number(&di->di_tv);
|
||||
}
|
||||
if ((di = tv_dict_find(dict, S_LEN("curswant"))) != NULL) {
|
||||
curwin->w_curswant = (colnr_T)tv_get_number(&di->di_tv);
|
||||
curwin->w_set_curswant = false;
|
||||
}
|
||||
if ((di = tv_dict_find(dict, S_LEN("topline"))) != NULL) {
|
||||
set_topline(curwin, (linenr_T)tv_get_number(&di->di_tv));
|
||||
}
|
||||
if ((di = tv_dict_find(dict, S_LEN("topfill"))) != NULL) {
|
||||
curwin->w_topfill = (int)tv_get_number(&di->di_tv);
|
||||
}
|
||||
if ((di = tv_dict_find(dict, S_LEN("leftcol"))) != NULL) {
|
||||
curwin->w_leftcol = (colnr_T)tv_get_number(&di->di_tv);
|
||||
}
|
||||
if ((di = tv_dict_find(dict, S_LEN("skipcol"))) != NULL) {
|
||||
curwin->w_skipcol = (colnr_T)tv_get_number(&di->di_tv);
|
||||
}
|
||||
|
||||
check_cursor();
|
||||
win_new_height(curwin, curwin->w_height);
|
||||
win_new_width(curwin, curwin->w_width);
|
||||
changed_window_setting();
|
||||
|
||||
if (curwin->w_topline <= 0) {
|
||||
curwin->w_topline = 1;
|
||||
}
|
||||
if (curwin->w_topline > curbuf->b_ml.ml_line_count) {
|
||||
curwin->w_topline = curbuf->b_ml.ml_line_count;
|
||||
}
|
||||
check_topfill(curwin, true);
|
||||
if (tv_check_for_nonnull_dict_arg(argvars, 0) == FAIL) {
|
||||
return;
|
||||
}
|
||||
|
||||
dict_T *dict = argvars[0].vval.v_dict;
|
||||
dictitem_T *di;
|
||||
if ((di = tv_dict_find(dict, S_LEN("lnum"))) != NULL) {
|
||||
curwin->w_cursor.lnum = (linenr_T)tv_get_number(&di->di_tv);
|
||||
}
|
||||
if ((di = tv_dict_find(dict, S_LEN("col"))) != NULL) {
|
||||
curwin->w_cursor.col = (colnr_T)tv_get_number(&di->di_tv);
|
||||
}
|
||||
if ((di = tv_dict_find(dict, S_LEN("coladd"))) != NULL) {
|
||||
curwin->w_cursor.coladd = (colnr_T)tv_get_number(&di->di_tv);
|
||||
}
|
||||
if ((di = tv_dict_find(dict, S_LEN("curswant"))) != NULL) {
|
||||
curwin->w_curswant = (colnr_T)tv_get_number(&di->di_tv);
|
||||
curwin->w_set_curswant = false;
|
||||
}
|
||||
if ((di = tv_dict_find(dict, S_LEN("topline"))) != NULL) {
|
||||
set_topline(curwin, (linenr_T)tv_get_number(&di->di_tv));
|
||||
}
|
||||
if ((di = tv_dict_find(dict, S_LEN("topfill"))) != NULL) {
|
||||
curwin->w_topfill = (int)tv_get_number(&di->di_tv);
|
||||
}
|
||||
if ((di = tv_dict_find(dict, S_LEN("leftcol"))) != NULL) {
|
||||
curwin->w_leftcol = (colnr_T)tv_get_number(&di->di_tv);
|
||||
}
|
||||
if ((di = tv_dict_find(dict, S_LEN("skipcol"))) != NULL) {
|
||||
curwin->w_skipcol = (colnr_T)tv_get_number(&di->di_tv);
|
||||
}
|
||||
|
||||
check_cursor();
|
||||
win_new_height(curwin, curwin->w_height);
|
||||
win_new_width(curwin, curwin->w_width);
|
||||
changed_window_setting();
|
||||
|
||||
if (curwin->w_topline <= 0) {
|
||||
curwin->w_topline = 1;
|
||||
}
|
||||
if (curwin->w_topline > curbuf->b_ml.ml_line_count) {
|
||||
curwin->w_topline = curbuf->b_ml.ml_line_count;
|
||||
}
|
||||
check_topfill(curwin, true);
|
||||
}
|
||||
|
||||
/// "winsaveview()" function
|
||||
|
@ -2204,8 +2204,7 @@ void f_mapset(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
const int mode = get_map_mode((char **)&which, 0);
|
||||
const bool is_abbr = tv_get_number(&argvars[1]) != 0;
|
||||
|
||||
if (argvars[2].v_type != VAR_DICT) {
|
||||
emsg(_(e_dictreq));
|
||||
if (tv_check_for_dict_arg(argvars, 2) == FAIL) {
|
||||
return;
|
||||
}
|
||||
dict_T *d = argvars[2].vval.v_dict;
|
||||
|
@ -2772,8 +2772,7 @@ void f_searchcount(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
dictitem_T *di;
|
||||
bool error = false;
|
||||
|
||||
if (argvars[0].v_type != VAR_DICT || argvars[0].vval.v_dict == NULL) {
|
||||
emsg(_(e_dictreq));
|
||||
if (tv_check_for_nonnull_dict_arg(argvars, 0) == FAIL) {
|
||||
return;
|
||||
}
|
||||
dict = argvars[0].vval.v_dict;
|
||||
@ -3348,8 +3347,7 @@ static void do_fuzzymatch(const typval_T *const argvars, typval_T *const rettv,
|
||||
bool matchseq = false;
|
||||
long max_matches = 0;
|
||||
if (argvars[2].v_type != VAR_UNKNOWN) {
|
||||
if (argvars[2].v_type != VAR_DICT || argvars[2].vval.v_dict == NULL) {
|
||||
emsg(_(e_dictreq));
|
||||
if (tv_check_for_nonnull_dict_arg(argvars, 2) == FAIL) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2017,8 +2017,7 @@ void f_sign_define(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
return;
|
||||
}
|
||||
|
||||
if (argvars[1].v_type != VAR_UNKNOWN && argvars[1].v_type != VAR_DICT) {
|
||||
emsg(_(e_dictreq));
|
||||
if (tv_check_for_opt_dict_arg(argvars, 1) == FAIL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2061,12 +2060,10 @@ void f_sign_getplaced(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
}
|
||||
|
||||
if (argvars[1].v_type != VAR_UNKNOWN) {
|
||||
dict_T *dict;
|
||||
if (argvars[1].v_type != VAR_DICT
|
||||
|| ((dict = argvars[1].vval.v_dict) == NULL)) {
|
||||
emsg(_(e_dictreq));
|
||||
if (tv_check_for_nonnull_dict_arg(argvars, 1) == FAIL) {
|
||||
return;
|
||||
}
|
||||
dict_T *dict = argvars[1].vval.v_dict;
|
||||
if ((di = tv_dict_find(dict, "lnum", -1)) != NULL) {
|
||||
// get signs placed at this line
|
||||
lnum = (linenr_T)tv_get_number_chk(&di->di_tv, ¬anum);
|
||||
@ -2263,11 +2260,11 @@ void f_sign_place(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
|
||||
rettv->vval.v_number = -1;
|
||||
|
||||
if (argvars[4].v_type != VAR_UNKNOWN
|
||||
&& (argvars[4].v_type != VAR_DICT
|
||||
|| ((dict = argvars[4].vval.v_dict) == NULL))) {
|
||||
emsg(_(e_dictreq));
|
||||
return;
|
||||
if (argvars[4].v_type != VAR_UNKNOWN) {
|
||||
if (tv_check_for_nonnull_dict_arg(argvars, 4) == FAIL) {
|
||||
return;
|
||||
}
|
||||
dict = argvars[4].vval.v_dict;
|
||||
}
|
||||
|
||||
rettv->vval.v_number = sign_place_from_dict(&argvars[0], &argvars[1], &argvars[2], &argvars[3],
|
||||
@ -2415,8 +2412,7 @@ void f_sign_unplace(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
}
|
||||
|
||||
if (argvars[1].v_type != VAR_UNKNOWN) {
|
||||
if (argvars[1].v_type != VAR_DICT) {
|
||||
emsg(_(e_dictreq));
|
||||
if (tv_check_for_dict_arg(argvars, 1) == FAIL) {
|
||||
return;
|
||||
}
|
||||
dict = argvars[1].vval.v_dict;
|
||||
|
@ -39,7 +39,7 @@ func Test_charsearch()
|
||||
call setcharsearch({'char' : ''})
|
||||
call assert_equal('', getcharsearch().char)
|
||||
|
||||
call assert_fails("call setcharsearch([])", 'E715:')
|
||||
call assert_fails("call setcharsearch([])", 'E1206:')
|
||||
enew!
|
||||
endfunc
|
||||
|
||||
|
@ -105,7 +105,7 @@ func Test_dict()
|
||||
END
|
||||
call CheckLegacyAndVim9Success(lines)
|
||||
|
||||
call CheckLegacyAndVim9Failure(["VAR i = has_key([], 'a')"], ['E715:', 'E1013:', 'E1206:'])
|
||||
call CheckLegacyAndVim9Failure(["VAR i = has_key([], 'a')"], ['E1206:', 'E1013:', 'E1206:'])
|
||||
endfunc
|
||||
|
||||
func Test_strgetchar()
|
||||
|
@ -2007,7 +2007,7 @@ func Test_call()
|
||||
endfunction
|
||||
let mydict = {'data': [0, 1, 2, 3], 'len': function("Mylen")}
|
||||
eval mydict.len->call([], mydict)->assert_equal(4)
|
||||
call assert_fails("call call('Mylen', [], 0)", 'E715:')
|
||||
call assert_fails("call call('Mylen', [], 0)", 'E1206:')
|
||||
call assert_fails('call foo', 'E107:')
|
||||
|
||||
" These once caused a crash.
|
||||
|
@ -699,7 +699,7 @@ func Test_reverse_sort_uniq()
|
||||
|
||||
call assert_fails('call reverse("")', 'E899:')
|
||||
call assert_fails('call uniq([1, 2], {x, y -> []})', 'E745:')
|
||||
call assert_fails("call sort([1, 2], function('min'), 1)", "E715:")
|
||||
call assert_fails("call sort([1, 2], function('min'), 1)", "E1206:")
|
||||
call assert_fails("call sort([1, 2], function('invalid_func'))", "E700:")
|
||||
call assert_fails("call sort([1, 2], function('min'))", "E118:")
|
||||
endfunc
|
||||
|
@ -270,7 +270,7 @@ func Test_mapset()
|
||||
bwipe!
|
||||
|
||||
call assert_fails('call mapset([], v:false, {})', 'E730:')
|
||||
call assert_fails('call mapset("i", 0, "")', 'E715:')
|
||||
call assert_fails('call mapset("i", 0, "")', 'E1206:')
|
||||
call assert_fails('call mapset("i", 0, {})', 'E460:')
|
||||
endfunc
|
||||
|
||||
|
@ -67,7 +67,7 @@ func Test_matchfuzzy()
|
||||
call assert_equal([{'id' : 6, 'val' : 'camera'}], matchfuzzy(l, 'cam', {'key' : 'val'}))
|
||||
call assert_equal([], matchfuzzy(l, 'day', {'text_cb' : {v -> v.val}}))
|
||||
call assert_equal([], matchfuzzy(l, 'day', {'key' : 'val'}))
|
||||
call assert_fails("let x = matchfuzzy(l, 'cam', 'random')", 'E715:')
|
||||
call assert_fails("let x = matchfuzzy(l, 'cam', 'random')", 'E1206:')
|
||||
call assert_equal([], matchfuzzy(l, 'day', {'text_cb' : {v -> []}}))
|
||||
call assert_equal([], matchfuzzy(l, 'day', {'text_cb' : {v -> 1}}))
|
||||
call assert_fails("let x = matchfuzzy(l, 'day', {'text_cb' : {a, b -> 1}})", 'E119:')
|
||||
@ -76,7 +76,7 @@ func Test_matchfuzzy()
|
||||
" call assert_fails("let x = matchfuzzy(l, 'cam', {'text_cb' : []})", 'E921:')
|
||||
call assert_fails("let x = matchfuzzy(l, 'cam', {'text_cb' : []})", 'E6000:')
|
||||
call assert_fails("let x = matchfuzzy(l, 'foo', {'key' : []})", 'E730:')
|
||||
call assert_fails("let x = matchfuzzy(l, 'cam', v:_null_dict)", 'E715:')
|
||||
call assert_fails("let x = matchfuzzy(l, 'cam', v:_null_dict)", 'E1297:')
|
||||
call assert_fails("let x = matchfuzzy(l, 'foo', {'key' : v:_null_string})", 'E475:')
|
||||
" Nvim doesn't have null functions
|
||||
" call assert_fails("let x = matchfuzzy(l, 'foo', {'text_cb' : test_null_function()})", 'E475:')
|
||||
@ -144,7 +144,7 @@ func Test_matchfuzzypos()
|
||||
\ matchfuzzypos(l, 'cam', {'key' : 'val'}))
|
||||
call assert_equal([[], [], []], matchfuzzypos(l, 'day', {'text_cb' : {v -> v.val}}))
|
||||
call assert_equal([[], [], []], matchfuzzypos(l, 'day', {'key' : 'val'}))
|
||||
call assert_fails("let x = matchfuzzypos(l, 'cam', 'random')", 'E715:')
|
||||
call assert_fails("let x = matchfuzzypos(l, 'cam', 'random')", 'E1206:')
|
||||
call assert_equal([[], [], []], matchfuzzypos(l, 'day', {'text_cb' : {v -> []}}))
|
||||
call assert_equal([[], [], []], matchfuzzypos(l, 'day', {'text_cb' : {v -> 1}}))
|
||||
call assert_fails("let x = matchfuzzypos(l, 'day', {'text_cb' : {a, b -> 1}})", 'E119:')
|
||||
@ -153,7 +153,7 @@ func Test_matchfuzzypos()
|
||||
" call assert_fails("let x = matchfuzzypos(l, 'cam', {'text_cb' : []})", 'E921:')
|
||||
call assert_fails("let x = matchfuzzypos(l, 'cam', {'text_cb' : []})", 'E6000:')
|
||||
call assert_fails("let x = matchfuzzypos(l, 'foo', {'key' : []})", 'E730:')
|
||||
call assert_fails("let x = matchfuzzypos(l, 'cam', v:_null_dict)", 'E715:')
|
||||
call assert_fails("let x = matchfuzzypos(l, 'cam', v:_null_dict)", 'E1297:')
|
||||
call assert_fails("let x = matchfuzzypos(l, 'foo', {'key' : v:_null_string})", 'E475:')
|
||||
" Nvim doesn't have null functions
|
||||
" call assert_fails("let x = matchfuzzypos(l, 'foo', {'text_cb' : test_null_function()})", 'E475:')
|
||||
|
@ -86,7 +86,7 @@ func Test_partial_dict()
|
||||
call assert_equal("Hello", dict.tr())
|
||||
|
||||
call assert_fails("let F=function('setloclist', 10)", "E923:")
|
||||
call assert_fails("let F=function('setloclist', [], [])", "E922:")
|
||||
call assert_fails("let F=function('setloclist', [], [])", "E1206:")
|
||||
endfunc
|
||||
|
||||
func Test_partial_implicit()
|
||||
|
@ -259,7 +259,7 @@ func Test_search_stat()
|
||||
endfunc
|
||||
|
||||
func Test_searchcount_fails()
|
||||
call assert_fails('echo searchcount("boo!")', 'E715:')
|
||||
call assert_fails('echo searchcount("boo!")', 'E1206:')
|
||||
call assert_fails('echo searchcount({"timeout" : []})', 'E745:')
|
||||
call assert_fails('echo searchcount({"maxcount" : []})', 'E745:')
|
||||
call assert_fails('echo searchcount({"pattern" : []})', 'E730:')
|
||||
|
@ -463,7 +463,7 @@ func Test_sign_funcs()
|
||||
call assert_fails('call sign_define("sign4", {"text" : "===>"})', 'E239:')
|
||||
" call assert_fails('call sign_define("sign5", {"text" : ""})', 'E239:')
|
||||
call assert_fails('call sign_define({})', 'E731:')
|
||||
call assert_fails('call sign_define("sign6", [])', 'E715:')
|
||||
call assert_fails('call sign_define("sign6", [])', 'E1206:')
|
||||
|
||||
" Tests for sign_getdefined()
|
||||
call assert_equal([], sign_getdefined("none"))
|
||||
@ -490,8 +490,7 @@ func Test_sign_funcs()
|
||||
" Tests for invalid arguments to sign_place()
|
||||
call assert_fails('call sign_place([], "", "mySign", 1)', 'E745:')
|
||||
call assert_fails('call sign_place(5, "", "mySign", -1)', 'E158:')
|
||||
call assert_fails('call sign_place(-1, "", "sign1", "Xsign", [])',
|
||||
\ 'E715:')
|
||||
call assert_fails('call sign_place(-1, "", "sign1", "Xsign", [])', 'E1206:')
|
||||
call assert_fails('call sign_place(-1, "", "sign1", "Xsign",
|
||||
\ {"lnum" : 30})', 'E474:')
|
||||
call assert_fails('call sign_place(10, "", "xsign1x", "Xsign",
|
||||
@ -526,7 +525,7 @@ func Test_sign_funcs()
|
||||
call assert_fails("call sign_getplaced('dummy.sign')", 'E158:')
|
||||
call assert_fails('call sign_getplaced("&")', 'E158:')
|
||||
call assert_fails('call sign_getplaced(-1)', 'E158:')
|
||||
call assert_fails('call sign_getplaced("Xsign", [])', 'E715:')
|
||||
call assert_fails('call sign_getplaced("Xsign", [])', 'E1206:')
|
||||
call assert_equal([{'bufnr' : bufnr(''), 'signs' : []}],
|
||||
\ sign_getplaced('Xsign', {'lnum' : 1000000}))
|
||||
call assert_fails("call sign_getplaced('Xsign', {'lnum' : []})",
|
||||
@ -549,7 +548,7 @@ func Test_sign_funcs()
|
||||
\ {'id' : 20, 'buffer' : '&'})", 'E158:')
|
||||
call assert_fails("call sign_unplace('g1',
|
||||
\ {'id' : 20, 'buffer' : 200})", 'E158:')
|
||||
call assert_fails("call sign_unplace('g1', 'mySign')", 'E715:')
|
||||
call assert_fails("call sign_unplace('g1', 'mySign')", 'E1206:')
|
||||
|
||||
call sign_unplace('*')
|
||||
|
||||
@ -1568,8 +1567,7 @@ func Test_sign_priority()
|
||||
\ s[0].signs)
|
||||
|
||||
" Error case
|
||||
call assert_fails("call sign_place(1, 'g1', 'sign1', 'Xsign',
|
||||
\ [])", 'E715:')
|
||||
call assert_fails("call sign_place(1, 'g1', 'sign1', 'Xsign', [])", 'E1206:')
|
||||
call assert_fails("call sign_place(1, 'g1', 'sign1', 'Xsign',
|
||||
\ {'priority' : []})", 'E745:')
|
||||
call sign_unplace('*')
|
||||
|
@ -405,10 +405,10 @@ func Test_getsettagstack()
|
||||
" Error cases
|
||||
call assert_equal({}, gettagstack(100))
|
||||
call assert_equal(-1, settagstack(100, {'items' : []}))
|
||||
call assert_fails('call settagstack(1, [1, 10])', 'E715')
|
||||
call assert_fails("call settagstack(1, {'items' : 10})", 'E714')
|
||||
call assert_fails("call settagstack(1, {'items' : []}, 10)", 'E928')
|
||||
call assert_fails("call settagstack(1, {'items' : []}, 'b')", 'E962')
|
||||
call assert_fails('call settagstack(1, [1, 10])', 'E1206:')
|
||||
call assert_fails("call settagstack(1, {'items' : 10})", 'E714:')
|
||||
call assert_fails("call settagstack(1, {'items' : []}, 10)", 'E928:')
|
||||
call assert_fails("call settagstack(1, {'items' : []}, 'b')", 'E962:')
|
||||
call assert_equal(-1, settagstack(0, v:_null_dict))
|
||||
|
||||
set tags=Xtags
|
||||
|
@ -228,7 +228,7 @@ func Test_timer_errors()
|
||||
sleep 50m
|
||||
call assert_equal(3, g:call_count)
|
||||
|
||||
call assert_fails('call timer_start(100, "MyHandler", "abc")', 'E475:')
|
||||
call assert_fails('call timer_start(100, "MyHandler", "abc")', 'E1206:')
|
||||
call assert_fails('call timer_start(100, [])', 'E921:')
|
||||
call assert_fails('call timer_stop("abc")', 'E39:')
|
||||
endfunc
|
||||
|
@ -735,7 +735,7 @@ func Test_relative_cursor_position_in_one_line_window()
|
||||
|
||||
only!
|
||||
bwipe!
|
||||
call assert_fails('call winrestview(v:_null_dict)', 'E474:')
|
||||
call assert_fails('call winrestview(v:_null_dict)', 'E1297:')
|
||||
endfunc
|
||||
|
||||
func Test_relative_cursor_position_after_move_and_resize()
|
||||
@ -936,7 +936,7 @@ func Test_winrestview()
|
||||
call assert_equal(view, winsaveview())
|
||||
|
||||
bwipe!
|
||||
call assert_fails('call winrestview(v:_null_dict)', 'E474:')
|
||||
call assert_fails('call winrestview(v:_null_dict)', 'E1297:')
|
||||
endfunc
|
||||
|
||||
func Test_win_splitmove()
|
||||
@ -967,7 +967,7 @@ func Test_win_splitmove()
|
||||
call assert_equal(bufname(winbufnr(2)), 'b')
|
||||
call assert_equal(bufname(winbufnr(3)), 'a')
|
||||
call assert_equal(bufname(winbufnr(4)), 'd')
|
||||
call assert_fails('call win_splitmove(winnr(), winnr("k"), v:_null_dict)', 'E474:')
|
||||
call assert_fails('call win_splitmove(winnr(), winnr("k"), v:_null_dict)', 'E1297:')
|
||||
only | bd
|
||||
|
||||
call assert_fails('call win_splitmove(winnr(), 123)', 'E957:')
|
||||
|
Loading…
Reference in New Issue
Block a user