mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.3188: Vim9: argument types are not checked at compile time
Problem: Vim9: argument types are not checked at compile time. Solution: Add several more type checks, also at runtime. (Yegappan Lakshmanan, closes #8587)
This commit is contained in:
parent
9bb0dad0d8
commit
83494b4ac6
@ -415,9 +415,16 @@ blob_set_range(blob_T *dest, long n1, long n2, typval_T *src)
|
||||
blob_remove(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
int error = FALSE;
|
||||
long idx = (long)tv_get_number_chk(&argvars[1], &error);
|
||||
long idx;
|
||||
long end;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_blob_arg(argvars, 0) == FAIL
|
||||
|| check_for_number_arg(argvars, 1) == FAIL
|
||||
|| check_for_opt_number_arg(argvars, 2) == FAIL))
|
||||
return;
|
||||
|
||||
idx = (long)tv_get_number_chk(&argvars[1], &error);
|
||||
if (!error)
|
||||
{
|
||||
blob_T *b = argvars[0].vval.v_blob;
|
||||
|
@ -4270,6 +4270,11 @@ ch_expr_common(typval_T *argvars, typval_T *rettv, int eval)
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = NULL;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_chan_or_job_arg(argvars, 0) == FAIL
|
||||
|| check_for_opt_dict_arg(argvars, 2) == FAIL))
|
||||
return;
|
||||
|
||||
channel = get_channel_arg(&argvars[0], TRUE, FALSE, 0);
|
||||
if (channel == NULL)
|
||||
return;
|
||||
@ -4330,6 +4335,12 @@ ch_raw_common(typval_T *argvars, typval_T *rettv, int eval)
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = NULL;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_chan_or_job_arg(argvars, 0) == FAIL
|
||||
|| check_for_string_or_blob_arg(argvars, 1) == FAIL
|
||||
|| check_for_opt_dict_arg(argvars, 2) == FAIL))
|
||||
return;
|
||||
|
||||
if (argvars[1].v_type == VAR_BLOB)
|
||||
{
|
||||
text = argvars[1].vval.v_blob->bv_ga.ga_data;
|
||||
@ -4815,9 +4826,16 @@ f_ch_close_in(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
void
|
||||
f_ch_getbufnr(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
channel_T *channel = get_channel_arg(&argvars[0], FALSE, FALSE, 0);
|
||||
channel_T *channel;
|
||||
|
||||
rettv->vval.v_number = -1;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_chan_or_job_arg(argvars, 0) == FAIL
|
||||
|| check_for_string_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
channel = get_channel_arg(&argvars[0], FALSE, FALSE, 0);
|
||||
if (channel != NULL)
|
||||
{
|
||||
char_u *what = tv_get_string(&argvars[1]);
|
||||
@ -4894,6 +4912,7 @@ f_ch_logfile(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
// Don't open a file in restricted mode.
|
||||
if (check_restricted() || check_secure())
|
||||
return;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_string_arg(argvars, 0) == FAIL
|
||||
|| check_for_string_arg(argvars, 1) == FAIL))
|
||||
|
@ -793,6 +793,15 @@ f_remote_expr(typval_T *argvars UNUSED, typval_T *rettv)
|
||||
{
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = NULL;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_string_arg(argvars, 0) == FAIL
|
||||
|| check_for_string_arg(argvars, 1) == FAIL
|
||||
|| check_for_opt_string_arg(argvars, 2) == FAIL
|
||||
|| (argvars[2].v_type != VAR_UNKNOWN
|
||||
&& check_for_opt_number_arg(argvars, 3) == FAIL)))
|
||||
return;
|
||||
|
||||
#ifdef FEAT_CLIENTSERVER
|
||||
remote_common(argvars, rettv, TRUE);
|
||||
#endif
|
||||
@ -891,8 +900,7 @@ f_remote_read(typval_T *argvars UNUSED, typval_T *rettv)
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_string_arg(argvars, 0) == FAIL
|
||||
|| (argvars[1].v_type != VAR_UNKNOWN
|
||||
&& check_for_number_arg(argvars, 1) == FAIL)))
|
||||
|| check_for_opt_number_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
serverid = tv_get_string_chk(&argvars[0]);
|
||||
@ -932,6 +940,13 @@ f_remote_send(typval_T *argvars UNUSED, typval_T *rettv)
|
||||
{
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = NULL;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_string_arg(argvars, 0) == FAIL
|
||||
|| check_for_string_arg(argvars, 1) == FAIL
|
||||
|| check_for_opt_string_arg(argvars, 2) == FAIL))
|
||||
return;
|
||||
|
||||
#ifdef FEAT_CLIENTSERVER
|
||||
remote_common(argvars, rettv, FALSE);
|
||||
#endif
|
||||
|
@ -2891,6 +2891,12 @@ f_getcompletion(typval_T *argvars, typval_T *rettv)
|
||||
int options = WILD_SILENT | WILD_USE_NL | WILD_ADD_SLASH
|
||||
| WILD_NO_BEEP;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_string_arg(argvars, 0) == FAIL
|
||||
|| check_for_string_arg(argvars, 1) == FAIL
|
||||
|| check_for_opt_bool_arg(argvars, 2) == FAIL))
|
||||
return;
|
||||
|
||||
if (argvars[1].v_type != VAR_STRING)
|
||||
{
|
||||
semsg(_(e_invarg2), "type must be a string");
|
||||
|
@ -599,8 +599,7 @@ f_histget(typval_T *argvars UNUSED, typval_T *rettv)
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_string_arg(argvars, 0) == FAIL
|
||||
|| (argvars[1].v_type != VAR_UNKNOWN
|
||||
&& check_for_number_arg(argvars, 1) == FAIL)))
|
||||
|| check_for_opt_number_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
str = tv_get_string_chk(&argvars[0]); // NULL on type error
|
||||
|
@ -1340,6 +1340,11 @@ dict_remove(typval_T *argvars, typval_T *rettv, char_u *arg_errmsg)
|
||||
char_u *key;
|
||||
dictitem_T *di;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_dict_arg(argvars, 0) == FAIL
|
||||
|| check_for_string_or_number_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
if (argvars[2].v_type != VAR_UNKNOWN)
|
||||
semsg(_(e_toomanyarg), "remove()");
|
||||
else if ((d = argvars[0].vval.v_dict) != NULL
|
||||
|
@ -3294,9 +3294,7 @@ f_diff_hlID(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
|
||||
int col;
|
||||
|
||||
if (in_vim9script()
|
||||
&& ((argvars[0].v_type != VAR_STRING
|
||||
&& argvars[0].v_type != VAR_NUMBER
|
||||
&& check_for_string_arg(argvars, 0) == FAIL)
|
||||
&& (check_for_string_or_number_arg(argvars,0) == FAIL
|
||||
|| check_for_number_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
|
@ -520,3 +520,9 @@ EXTERN char e_digraph_argument_must_be_one_character_str[]
|
||||
EXTERN char e_setdigraphlist_argument_must_be_list_of_lists_with_two_items[]
|
||||
INIT(= N_("E1216: setdigraphlist() argument must be a list of lists with two items"));
|
||||
#endif
|
||||
EXTERN char e_blob_required_for_argument_nr[]
|
||||
INIT(= N_("E1217: Blob required for argument %d"));
|
||||
EXTERN char e_chan_or_job_required_for_argument_nr[]
|
||||
INIT(= N_("E1218: Channel or Job required for argument %d"));
|
||||
EXTERN char e_job_required_for_argument_nr[]
|
||||
INIT(= N_("E1219: Job required for argument %d"));
|
||||
|
@ -4184,6 +4184,15 @@ check_can_index(typval_T *rettv, int evaluate, int verbose)
|
||||
void
|
||||
f_slice(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
if (in_vim9script()
|
||||
&& ((argvars[0].v_type != VAR_LIST
|
||||
&& argvars[0].v_type != VAR_BLOB
|
||||
&& argvars[0].v_type != VAR_STRING
|
||||
&& check_for_list_arg(argvars, 0) == FAIL)
|
||||
|| check_for_number_arg(argvars, 1) == FAIL
|
||||
|| check_for_opt_number_arg(argvars, 2) == FAIL))
|
||||
return;
|
||||
|
||||
if (check_can_index(argvars, TRUE, FALSE) == OK)
|
||||
{
|
||||
copy_tv(argvars, rettv);
|
||||
|
@ -387,6 +387,12 @@ f_bufnr(typval_T *argvars, typval_T *rettv)
|
||||
int error = FALSE;
|
||||
char_u *name;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_opt_string_or_number_arg(argvars, 0) == FAIL
|
||||
|| (argvars[0].v_type != VAR_UNKNOWN
|
||||
&& check_for_opt_bool_arg(argvars, 1) == FAIL)))
|
||||
return;
|
||||
|
||||
if (argvars[0].v_type == VAR_UNKNOWN)
|
||||
buf = curbuf;
|
||||
else
|
||||
@ -459,6 +465,12 @@ f_deletebufline(typval_T *argvars, typval_T *rettv)
|
||||
tabpage_T *tp;
|
||||
win_T *wp;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_buffer_arg(argvars, 0) == FAIL
|
||||
|| check_for_lnum_arg(argvars, 1) == FAIL
|
||||
|| check_for_opt_lnum_arg(argvars, 2) == FAIL))
|
||||
return;
|
||||
|
||||
buf = tv_get_buf(&argvars[0], FALSE);
|
||||
if (buf == NULL)
|
||||
{
|
||||
@ -727,6 +739,12 @@ f_getbufline(typval_T *argvars, typval_T *rettv)
|
||||
linenr_T end = 1;
|
||||
buf_T *buf;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_buffer_arg(argvars, 0) == FAIL
|
||||
|| check_for_lnum_arg(argvars, 1) == FAIL
|
||||
|| check_for_opt_lnum_arg(argvars, 2) == FAIL))
|
||||
return;
|
||||
|
||||
buf = tv_get_buf_from_arg(&argvars[0]);
|
||||
if (buf != NULL)
|
||||
{
|
||||
|
488
src/evalfunc.c
488
src/evalfunc.c
File diff suppressed because it is too large
Load Diff
@ -4039,6 +4039,11 @@ f_gettabvar(typval_T *argvars, typval_T *rettv)
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = NULL;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_number_arg(argvars, 0) == FAIL
|
||||
|| check_for_string_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
varname = tv_get_string_chk(&argvars[1]);
|
||||
tp = find_tabpage((int)tv_get_number_chk(&argvars[0], NULL));
|
||||
if (tp != NULL && varname != NULL)
|
||||
@ -4073,6 +4078,12 @@ f_gettabvar(typval_T *argvars, typval_T *rettv)
|
||||
void
|
||||
f_gettabwinvar(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
if (in_vim9script()
|
||||
&& (check_for_number_arg(argvars, 0) == FAIL
|
||||
|| check_for_number_arg(argvars, 1) == FAIL
|
||||
|| check_for_string_arg(argvars, 2) == FAIL))
|
||||
return;
|
||||
|
||||
getwinvar(argvars, rettv, 1);
|
||||
}
|
||||
|
||||
@ -4082,6 +4093,11 @@ f_gettabwinvar(typval_T *argvars, typval_T *rettv)
|
||||
void
|
||||
f_getwinvar(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
if (in_vim9script()
|
||||
&& (check_for_number_arg(argvars, 0) == FAIL
|
||||
|| check_for_string_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
getwinvar(argvars, rettv, 0);
|
||||
}
|
||||
|
||||
@ -4165,6 +4181,11 @@ f_settabvar(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
if (check_secure())
|
||||
return;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_number_arg(argvars, 0) == FAIL
|
||||
|| check_for_string_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
tp = find_tabpage((int)tv_get_number_chk(&argvars[0], NULL));
|
||||
varname = tv_get_string_chk(&argvars[1]);
|
||||
varp = &argvars[2];
|
||||
@ -4195,6 +4216,12 @@ f_settabvar(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
void
|
||||
f_settabwinvar(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
{
|
||||
if (in_vim9script()
|
||||
&& (check_for_number_arg(argvars, 0) == FAIL
|
||||
|| check_for_number_arg(argvars, 1) == FAIL
|
||||
|| check_for_string_arg(argvars, 2) == FAIL))
|
||||
return;
|
||||
|
||||
setwinvar(argvars, 1);
|
||||
}
|
||||
|
||||
@ -4204,6 +4231,11 @@ f_settabwinvar(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
void
|
||||
f_setwinvar(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
{
|
||||
if (in_vim9script()
|
||||
&& (check_for_number_arg(argvars, 0) == FAIL
|
||||
|| check_for_string_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
setwinvar(argvars, 0);
|
||||
}
|
||||
|
||||
|
@ -655,8 +655,7 @@ f_tabpagewinnr(typval_T *argvars UNUSED, typval_T *rettv)
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_number_arg(argvars, 0) == FAIL
|
||||
|| (argvars[1].v_type != VAR_UNKNOWN
|
||||
&& check_for_string_arg(argvars, 1) == FAIL)))
|
||||
|| check_for_opt_string_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
tp = find_tabpage((int)tv_get_number(&argvars[0]));
|
||||
@ -834,6 +833,12 @@ f_win_splitmove(typval_T *argvars, typval_T *rettv)
|
||||
win_T *targetwin;
|
||||
int flags = 0, size = 0;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_number_arg(argvars, 0) == FAIL
|
||||
|| check_for_number_arg(argvars, 1) == FAIL
|
||||
|| check_for_opt_dict_arg(argvars, 2) == FAIL))
|
||||
return;
|
||||
|
||||
wp = find_win_by_nr_or_id(&argvars[0]);
|
||||
targetwin = find_win_by_nr_or_id(&argvars[1]);
|
||||
|
||||
|
@ -1254,6 +1254,15 @@ f_glob(typval_T *argvars, typval_T *rettv)
|
||||
expand_T xpc;
|
||||
int error = FALSE;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_string_arg(argvars, 0) == FAIL
|
||||
|| check_for_opt_bool_arg(argvars, 1) == FAIL
|
||||
|| (argvars[1].v_type != VAR_UNKNOWN
|
||||
&& (check_for_opt_bool_arg(argvars, 2) == FAIL
|
||||
|| (argvars[2].v_type != VAR_UNKNOWN
|
||||
&& check_for_opt_bool_arg(argvars, 3) == FAIL)))))
|
||||
return;
|
||||
|
||||
// When the optional second argument is non-zero, don't remove matches
|
||||
// for 'wildignore' and don't put matches for 'suffixes' at the end.
|
||||
rettv->v_type = VAR_STRING;
|
||||
@ -1318,11 +1327,23 @@ f_globpath(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
int flags = WILD_IGNORE_COMPLETESLASH;
|
||||
char_u buf1[NUMBUFLEN];
|
||||
char_u *file = tv_get_string_buf_chk(&argvars[1], buf1);
|
||||
char_u *file;
|
||||
int error = FALSE;
|
||||
garray_T ga;
|
||||
int i;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_string_arg(argvars, 0) == FAIL
|
||||
|| check_for_string_arg(argvars, 1) == FAIL
|
||||
|| check_for_opt_bool_arg(argvars, 2) == FAIL
|
||||
|| (argvars[2].v_type != VAR_UNKNOWN
|
||||
&& (check_for_opt_bool_arg(argvars, 3) == FAIL
|
||||
|| (argvars[3].v_type != VAR_UNKNOWN
|
||||
&& check_for_opt_bool_arg(argvars, 4) == FAIL)))))
|
||||
return;
|
||||
|
||||
file = tv_get_string_buf_chk(&argvars[1], buf1);
|
||||
|
||||
// When the optional second argument is non-zero, don't remove matches
|
||||
// for 'wildignore' and don't put matches for 'suffixes' at the end.
|
||||
rettv->v_type = VAR_STRING;
|
||||
@ -1449,8 +1470,7 @@ f_pathshorten(typval_T *argvars, typval_T *rettv)
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_string_arg(argvars, 0) == FAIL
|
||||
|| (argvars[1].v_type != VAR_UNKNOWN
|
||||
&& check_for_number_arg(argvars, 1) == FAIL)))
|
||||
|| check_for_opt_number_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
if (argvars[1].v_type != VAR_UNKNOWN)
|
||||
@ -2423,10 +2443,12 @@ f_browse(typval_T *argvars UNUSED, typval_T *rettv)
|
||||
int error = FALSE;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_string_arg(argvars, 1) == FAIL
|
||||
&& (check_for_bool_arg(argvars, 0) == FAIL
|
||||
|| check_for_string_arg(argvars, 1) == FAIL
|
||||
|| check_for_string_arg(argvars, 2) == FAIL
|
||||
|| check_for_string_arg(argvars, 3) == FAIL))
|
||||
return;
|
||||
|
||||
save = (int)tv_get_number_chk(&argvars[0], &error);
|
||||
title = tv_get_string_chk(&argvars[1]);
|
||||
initdir = tv_get_string_buf_chk(&argvars[2], buf);
|
||||
|
@ -1700,10 +1700,11 @@ EXTERN char e_readonlyvar[] INIT(= N_("E46: Cannot change read-only variable \"%
|
||||
EXTERN char e_readonlysbx[] INIT(= N_("E794: Cannot set variable in the sandbox: \"%s\""));
|
||||
EXTERN char e_stringreq[] INIT(= N_("E928: String required"));
|
||||
EXTERN char e_numberreq[] INIT(= N_("E889: Number required"));
|
||||
EXTERN char e_boolreq[] INIT(= N_("E839: Number required"));
|
||||
EXTERN char e_boolreq[] INIT(= N_("E839: Bool required"));
|
||||
EXTERN char e_emptykey[] INIT(= N_("E713: Cannot use empty key for Dictionary"));
|
||||
EXTERN char e_dictreq[] INIT(= N_("E715: Dictionary required"));
|
||||
EXTERN char e_listidx[] INIT(= N_("E684: list index out of range: %ld"));
|
||||
EXTERN char e_blobreq[] INIT(= N_("E538: Dictionary required"));
|
||||
EXTERN char e_blobidx[] INIT(= N_("E979: Blob index out of range: %ld"));
|
||||
EXTERN char e_invalblob[] INIT(= N_("E978: Invalid operation for Blob"));
|
||||
EXTERN char e_toomanyarg[] INIT(= N_("E118: Too many arguments for function: %s"));
|
||||
@ -1810,6 +1811,8 @@ EXTERN char e_lock_unlock[] INIT(= N_("E940: Cannot lock or unlock variable %s")
|
||||
#if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
|
||||
EXTERN char e_alloc_color[] INIT(= N_("E254: Cannot allocate color %s"));
|
||||
#endif
|
||||
EXTERN char e_chan_or_job_req[] INIT(= N_("E706: Channel or Job required"));
|
||||
EXTERN char e_jobreq[] INIT(= N_("E693: Job required"));
|
||||
|
||||
EXTERN char top_bot_msg[] INIT(= N_("search hit TOP, continuing at BOTTOM"));
|
||||
EXTERN char bot_top_msg[] INIT(= N_("search hit BOTTOM, continuing at TOP"));
|
||||
|
@ -2436,6 +2436,11 @@ f_complete(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
int startcol;
|
||||
int save_textlock = textlock;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_number_arg(argvars, 0) == FAIL
|
||||
|| check_for_list_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
if ((State & INSERT) == 0)
|
||||
{
|
||||
emsg(_("E785: complete() can only be used in Insert mode"));
|
||||
@ -2468,6 +2473,12 @@ f_complete(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
void
|
||||
f_complete_add(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
if (in_vim9script()
|
||||
&& (argvars[0].v_type != VAR_DICT
|
||||
&& argvars[0].v_type != VAR_STRING
|
||||
&& check_for_string_arg(argvars, 0) == FAIL))
|
||||
return;
|
||||
|
||||
rettv->vval.v_number = ins_compl_add_tv(&argvars[0], 0, FALSE);
|
||||
}
|
||||
|
||||
|
20
src/job.c
20
src/job.c
@ -1726,9 +1726,7 @@ f_prompt_setprompt(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
char_u *text;
|
||||
|
||||
if (in_vim9script()
|
||||
&& ((argvars[0].v_type != VAR_STRING
|
||||
&& argvars[0].v_type != VAR_NUMBER
|
||||
&& check_for_string_arg(argvars, 0) == FAIL)
|
||||
&& (check_for_string_or_number_arg(argvars, 0) == FAIL
|
||||
|| check_for_string_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
@ -1875,9 +1873,15 @@ f_job_info(typval_T *argvars, typval_T *rettv)
|
||||
void
|
||||
f_job_setoptions(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
{
|
||||
job_T *job = get_job_arg(&argvars[0]);
|
||||
job_T *job;
|
||||
jobopt_T opt;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_job_arg(argvars, 0) == FAIL
|
||||
|| check_for_dict_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
job = get_job_arg(&argvars[0]);
|
||||
if (job == NULL)
|
||||
return;
|
||||
clear_job_options(&opt);
|
||||
@ -1928,8 +1932,14 @@ f_job_status(typval_T *argvars, typval_T *rettv)
|
||||
void
|
||||
f_job_stop(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
job_T *job = get_job_arg(&argvars[0]);
|
||||
job_T *job;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_job_arg(argvars, 0) == FAIL
|
||||
|| check_for_opt_string_or_number_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
job = get_job_arg(&argvars[0]);
|
||||
if (job != NULL)
|
||||
rettv->vval.v_number = job_stop(job, argvars, NULL);
|
||||
}
|
||||
|
32
src/list.c
32
src/list.c
@ -823,6 +823,11 @@ flatten_common(typval_T *argvars, typval_T *rettv, int make_copy)
|
||||
long maxdepth;
|
||||
int error = FALSE;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_list_arg(argvars, 0) == FAIL
|
||||
|| check_for_opt_number_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
if (argvars[0].v_type != VAR_LIST)
|
||||
{
|
||||
semsg(_(e_listarg), "flatten()");
|
||||
@ -1267,6 +1272,11 @@ f_join(typval_T *argvars, typval_T *rettv)
|
||||
garray_T ga;
|
||||
char_u *sep;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_list_arg(argvars, 0) == FAIL
|
||||
|| check_for_opt_string_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
if (argvars[0].v_type != VAR_LIST)
|
||||
{
|
||||
emsg(_(e_listreq));
|
||||
@ -1470,6 +1480,12 @@ f_list2str(typval_T *argvars, typval_T *rettv)
|
||||
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = NULL;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_list_arg(argvars, 0) == FAIL
|
||||
|| check_for_opt_bool_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
if (argvars[0].v_type != VAR_LIST)
|
||||
{
|
||||
emsg(_(e_invarg));
|
||||
@ -1522,6 +1538,12 @@ list_remove(typval_T *argvars, typval_T *rettv, char_u *arg_errmsg)
|
||||
int error = FALSE;
|
||||
long idx;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_list_arg(argvars, 0) == FAIL
|
||||
|| check_for_number_arg(argvars, 1) == FAIL
|
||||
|| check_for_opt_number_arg(argvars, 2) == FAIL))
|
||||
return;
|
||||
|
||||
if ((l = argvars[0].vval.v_list) == NULL
|
||||
|| value_check_lock(l->lv_lock, arg_errmsg, TRUE))
|
||||
return;
|
||||
@ -2489,6 +2511,16 @@ f_count(typval_T *argvars, typval_T *rettv)
|
||||
int ic = FALSE;
|
||||
int error = FALSE;
|
||||
|
||||
if (in_vim9script()
|
||||
&& ((argvars[0].v_type != VAR_STRING
|
||||
&& argvars[0].v_type != VAR_LIST
|
||||
&& argvars[0].v_type != VAR_DICT
|
||||
&& check_for_string_arg(argvars, 0) == FAIL)
|
||||
|| check_for_opt_bool_arg(argvars, 2) == FAIL
|
||||
|| (argvars[2].v_type != VAR_UNKNOWN
|
||||
&& check_for_opt_number_arg(argvars, 3) == FAIL)))
|
||||
return;
|
||||
|
||||
if (argvars[2].v_type != VAR_UNKNOWN)
|
||||
ic = (int)tv_get_bool_chk(&argvars[2], &error);
|
||||
|
||||
|
@ -2316,6 +2316,12 @@ f_mapset(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
int nowait;
|
||||
char_u *arg;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_string_arg(argvars, 0) == FAIL
|
||||
|| check_for_bool_arg(argvars, 1) == FAIL
|
||||
|| check_for_dict_arg(argvars, 2) == FAIL))
|
||||
return;
|
||||
|
||||
which = tv_get_string_buf_chk(&argvars[0], buf);
|
||||
if (which == NULL)
|
||||
return;
|
||||
|
@ -1045,14 +1045,21 @@ f_setmatches(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
|
||||
listitem_T *li;
|
||||
dict_T *d;
|
||||
list_T *s = NULL;
|
||||
win_T *win = get_optional_window(argvars, 1);
|
||||
win_T *win;
|
||||
|
||||
rettv->vval.v_number = -1;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_list_arg(argvars, 0) == FAIL
|
||||
|| check_for_opt_number_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
if (argvars[0].v_type != VAR_LIST)
|
||||
{
|
||||
emsg(_(e_listreq));
|
||||
return;
|
||||
}
|
||||
win = get_optional_window(argvars, 1);
|
||||
if (win == NULL)
|
||||
return;
|
||||
|
||||
|
@ -11,10 +11,24 @@ varnumber_T tv_get_bool_chk(typval_T *varp, int *denote);
|
||||
float_T tv_get_float(typval_T *varp);
|
||||
int check_for_string_arg(typval_T *args, int idx);
|
||||
int check_for_nonempty_string_arg(typval_T *args, int idx);
|
||||
int check_for_opt_string_arg(typval_T *args, int idx);
|
||||
int check_for_number_arg(typval_T *args, int idx);
|
||||
int check_for_opt_number_arg(typval_T *args, int idx);
|
||||
int check_for_bool_arg(typval_T *args, int idx);
|
||||
int check_for_opt_bool_arg(typval_T *args, int idx);
|
||||
int check_for_list_arg(typval_T *args, int idx);
|
||||
int check_for_opt_list_arg(typval_T *args, int idx);
|
||||
int check_for_dict_arg(typval_T *args, int idx);
|
||||
int check_for_opt_dict_arg(typval_T *args, int idx);
|
||||
int check_for_blob_arg(typval_T *args, int idx);
|
||||
int check_for_chan_or_job_arg(typval_T *args, int idx);
|
||||
int check_for_job_arg(typval_T *args, int idx);
|
||||
int check_for_string_or_number_arg(typval_T *args, int idx);
|
||||
int check_for_buffer_arg(typval_T *args, int idx);
|
||||
int check_for_lnum_arg(typval_T *args, int idx);
|
||||
int check_for_opt_lnum_arg(typval_T *args, int idx);
|
||||
int check_for_opt_string_or_number_arg(typval_T *args, int idx);
|
||||
int check_for_string_or_blob_arg(typval_T *args, int idx);
|
||||
char_u *tv_get_string(typval_T *varp);
|
||||
char_u *tv_get_string_strict(typval_T *varp);
|
||||
char_u *tv_get_string_buf(typval_T *varp, char_u *buf);
|
||||
|
@ -8466,6 +8466,14 @@ f_setloclist(typval_T *argvars, typval_T *rettv)
|
||||
|
||||
rettv->vval.v_number = -1;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_number_arg(argvars, 0) == FAIL
|
||||
|| check_for_list_arg(argvars, 1) == FAIL
|
||||
|| check_for_opt_string_arg(argvars, 2) == FAIL
|
||||
|| (argvars[2].v_type != VAR_UNKNOWN
|
||||
&& check_for_opt_dict_arg(argvars, 3) == FAIL)))
|
||||
return;
|
||||
|
||||
win = find_win_by_nr_or_id(&argvars[0]);
|
||||
if (win != NULL)
|
||||
set_qf_ll_list(win, &argvars[1], &argvars[2], &argvars[3], rettv);
|
||||
@ -8477,6 +8485,13 @@ f_setloclist(typval_T *argvars, typval_T *rettv)
|
||||
void
|
||||
f_setqflist(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
if (in_vim9script()
|
||||
&& (check_for_list_arg(argvars, 0) == FAIL
|
||||
|| check_for_opt_string_arg(argvars, 1) == FAIL
|
||||
|| (argvars[1].v_type != VAR_UNKNOWN
|
||||
&& check_for_opt_dict_arg(argvars, 2) == FAIL)))
|
||||
return;
|
||||
|
||||
set_qf_ll_list(NULL, &argvars[0], &argvars[1], &argvars[2], rettv);
|
||||
}
|
||||
#endif
|
||||
|
26
src/search.c
26
src/search.c
@ -1217,7 +1217,8 @@ first_submatch(regmmatch_T *rp)
|
||||
do_search(
|
||||
oparg_T *oap, // can be NULL
|
||||
int dirc, // '/' or '?'
|
||||
int search_delim, // the delimiter for the search, e.g. '%' in s%regex%replacement%
|
||||
int search_delim, // the delimiter for the search, e.g. '%' in
|
||||
// s%regex%replacement%
|
||||
char_u *pat,
|
||||
long count,
|
||||
int options,
|
||||
@ -1476,11 +1477,11 @@ do_search(
|
||||
msgbuf = trunc;
|
||||
}
|
||||
|
||||
#ifdef FEAT_RIGHTLEFT
|
||||
// The search pattern could be shown on the right in rightleft
|
||||
// mode, but the 'ruler' and 'showcmd' area use it too, thus
|
||||
// it would be blanked out again very soon. Show it on the
|
||||
// left, but do reverse the text.
|
||||
#ifdef FEAT_RIGHTLEFT
|
||||
// The search pattern could be shown on the right in
|
||||
// rightleft mode, but the 'ruler' and 'showcmd' area use
|
||||
// it too, thus it would be blanked out again very soon.
|
||||
// Show it on the left, but do reverse the text.
|
||||
if (curwin->w_p_rl && *curwin->w_p_rlc == 's')
|
||||
{
|
||||
char_u *r;
|
||||
@ -1503,7 +1504,7 @@ do_search(
|
||||
vim_memset(msgbuf + pat_len, ' ', r - msgbuf);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
msg_outtrans(msgbuf);
|
||||
msg_clr_eos();
|
||||
msg_check();
|
||||
@ -1548,6 +1549,9 @@ do_search(
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The actual search.
|
||||
*/
|
||||
c = searchit(curwin, curbuf, &pos, NULL,
|
||||
dirc == '/' ? FORWARD : BACKWARD,
|
||||
searchstr, count, spats[0].off.end + (options &
|
||||
@ -1557,7 +1561,7 @@ do_search(
|
||||
RE_LAST, sia);
|
||||
|
||||
if (dircp != NULL)
|
||||
*dircp = search_delim; // restore second '/' or '?' for normal_cmd()
|
||||
*dircp = search_delim; // restore second '/' or '?' for normal_cmd()
|
||||
|
||||
if (!shortmess(SHM_SEARCH)
|
||||
&& ((dirc == '/' && LT_POS(pos, curwin->w_cursor))
|
||||
@ -4794,6 +4798,12 @@ do_fuzzymatch(typval_T *argvars, typval_T *rettv, int retmatchpos)
|
||||
int ret;
|
||||
int matchseq = FALSE;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_list_arg(argvars, 0) == FAIL
|
||||
|| check_for_string_arg(argvars, 1) == FAIL
|
||||
|| check_for_opt_dict_arg(argvars, 2) == FAIL))
|
||||
return;
|
||||
|
||||
CLEAR_POINTER(&cb);
|
||||
|
||||
// validate and get the arguments
|
||||
|
@ -2300,6 +2300,12 @@ f_sign_getplaced(typval_T *argvars, typval_T *rettv)
|
||||
if (rettv_list_alloc_id(rettv, aid_sign_getplaced) != OK)
|
||||
return;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_opt_string_or_number_arg(argvars, 0) == FAIL
|
||||
|| (argvars[0].v_type != VAR_UNKNOWN
|
||||
&& check_for_opt_dict_arg(argvars, 1) == FAIL)))
|
||||
return;
|
||||
|
||||
if (argvars[0].v_type != VAR_UNKNOWN)
|
||||
{
|
||||
// get signs placed in the specified buffer
|
||||
|
@ -904,8 +904,7 @@ f_str2list(typval_T *argvars, typval_T *rettv)
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_string_arg(argvars, 0) == FAIL
|
||||
|| (argvars[1].v_type != VAR_UNKNOWN
|
||||
&& check_for_bool_arg(argvars, 1) == FAIL)))
|
||||
|| check_for_opt_bool_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
if (argvars[1].v_type != VAR_UNKNOWN)
|
||||
@ -1116,8 +1115,7 @@ f_strchars(typval_T *argvars, typval_T *rettv)
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_string_arg(argvars, 0) == FAIL
|
||||
|| (argvars[1].v_type != VAR_UNKNOWN
|
||||
&& check_for_bool_arg(argvars, 1) == FAIL)))
|
||||
|| check_for_opt_bool_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
if (argvars[1].v_type != VAR_UNKNOWN)
|
||||
@ -1141,8 +1139,7 @@ f_strdisplaywidth(typval_T *argvars, typval_T *rettv)
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_string_arg(argvars, 0) == FAIL
|
||||
|| (argvars[1].v_type != VAR_UNKNOWN
|
||||
&& check_for_number_arg(argvars, 1) == FAIL)))
|
||||
|| check_for_opt_number_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
s = tv_get_string(&argvars[0]);
|
||||
@ -1178,6 +1175,14 @@ f_strcharpart(typval_T *argvars, typval_T *rettv)
|
||||
int slen;
|
||||
int error = FALSE;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_string_arg(argvars, 0) == FAIL
|
||||
|| check_for_number_arg(argvars, 1) == FAIL
|
||||
|| check_for_opt_number_arg(argvars, 2) == FAIL
|
||||
|| (argvars[2].v_type != VAR_UNKNOWN
|
||||
&& check_for_opt_bool_arg(argvars, 3) == FAIL)))
|
||||
return;
|
||||
|
||||
p = tv_get_string(&argvars[0]);
|
||||
slen = (int)STRLEN(p);
|
||||
|
||||
@ -1261,6 +1266,14 @@ f_strpart(typval_T *argvars, typval_T *rettv)
|
||||
int slen;
|
||||
int error = FALSE;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_string_arg(argvars, 0) == FAIL
|
||||
|| check_for_number_arg(argvars, 1) == FAIL
|
||||
|| check_for_opt_number_arg(argvars, 2) == FAIL
|
||||
|| (argvars[2].v_type != VAR_UNKNOWN
|
||||
&& check_for_opt_bool_arg(argvars, 3) == FAIL)))
|
||||
return;
|
||||
|
||||
p = tv_get_string(&argvars[0]);
|
||||
slen = (int)STRLEN(p);
|
||||
|
||||
|
@ -5928,11 +5928,17 @@ f_term_gettitle(typval_T *argvars, typval_T *rettv)
|
||||
void
|
||||
f_term_gettty(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
buf_T *buf = term_get_buf(argvars, "term_gettty()");
|
||||
buf_T *buf;
|
||||
char_u *p = NULL;
|
||||
int num = 0;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_string_or_number_arg(argvars, 0) == FAIL
|
||||
|| check_for_opt_bool_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
rettv->v_type = VAR_STRING;
|
||||
buf = term_get_buf(argvars, "term_gettty()");
|
||||
if (buf == NULL)
|
||||
return;
|
||||
if (argvars[1].v_type != VAR_UNKNOWN)
|
||||
@ -6098,9 +6104,7 @@ f_term_sendkeys(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
term_T *term;
|
||||
|
||||
if (in_vim9script()
|
||||
&& ((argvars[0].v_type != VAR_STRING
|
||||
&& argvars[0].v_type != VAR_NUMBER
|
||||
&& check_for_string_arg(argvars, 0) == FAIL)
|
||||
&& (check_for_string_or_number_arg(argvars, 0) == FAIL
|
||||
|| check_for_string_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
@ -6175,9 +6179,16 @@ f_term_getansicolors(typval_T *argvars, typval_T *rettv)
|
||||
void
|
||||
f_term_setansicolors(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
{
|
||||
buf_T *buf = term_get_buf(argvars, "term_setansicolors()");
|
||||
buf_T *buf;
|
||||
term_T *term;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_opt_string_or_number_arg(argvars, 0) == FAIL
|
||||
|| (argvars[0].v_type != VAR_UNKNOWN
|
||||
&& check_for_opt_list_arg(argvars, 1) == FAIL)))
|
||||
return;
|
||||
|
||||
buf = term_get_buf(argvars, "term_setansicolors()");
|
||||
if (buf == NULL)
|
||||
return;
|
||||
term = buf->b_term;
|
||||
@ -6206,9 +6217,7 @@ f_term_setapi(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
char_u *api;
|
||||
|
||||
if (in_vim9script()
|
||||
&& ((argvars[0].v_type != VAR_STRING
|
||||
&& argvars[0].v_type != VAR_NUMBER
|
||||
&& check_for_string_arg(argvars, 0) == FAIL)
|
||||
&& (check_for_string_or_number_arg(argvars, 0) == FAIL
|
||||
|| check_for_string_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
@ -6236,9 +6245,7 @@ f_term_setrestore(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
|
||||
char_u *cmd;
|
||||
|
||||
if (in_vim9script()
|
||||
&& ((argvars[0].v_type != VAR_STRING
|
||||
&& argvars[0].v_type != VAR_NUMBER
|
||||
&& check_for_string_arg(argvars, 0) == FAIL)
|
||||
&& (check_for_string_or_number_arg(argvars, 0) == FAIL
|
||||
|| check_for_string_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
@ -6266,9 +6273,7 @@ f_term_setkill(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
|
||||
char_u *how;
|
||||
|
||||
if (in_vim9script()
|
||||
&& ((argvars[0].v_type != VAR_STRING
|
||||
&& argvars[0].v_type != VAR_NUMBER
|
||||
&& check_for_string_arg(argvars, 0) == FAIL)
|
||||
&& (check_for_string_or_number_arg(argvars, 0) == FAIL
|
||||
|| check_for_string_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
@ -6321,11 +6326,8 @@ f_term_wait(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
buf_T *buf;
|
||||
|
||||
if (in_vim9script()
|
||||
&& ((argvars[0].v_type != VAR_STRING
|
||||
&& argvars[0].v_type != VAR_NUMBER
|
||||
&& check_for_string_arg(argvars, 0) == FAIL) ||
|
||||
(argvars[1].v_type != VAR_UNKNOWN
|
||||
&& check_for_number_arg(argvars, 1) == FAIL)))
|
||||
&& (check_for_string_or_number_arg(argvars, 0) == FAIL
|
||||
|| check_for_opt_number_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
buf = term_get_buf(argvars, "term_wait()");
|
||||
|
@ -423,24 +423,6 @@ func Test_blob_func_remove()
|
||||
END
|
||||
call CheckLegacyAndVim9Failure(lines, 'E979:')
|
||||
|
||||
let lines =<< trim END
|
||||
VAR b = 0zDEADBEEF
|
||||
call remove(1, 0)
|
||||
END
|
||||
call CheckLegacyAndVim9Failure(lines, 'E896:')
|
||||
|
||||
let lines =<< trim END
|
||||
VAR b = 0zDEADBEEF
|
||||
call remove(b, b)
|
||||
END
|
||||
call CheckLegacyAndVim9Failure(lines, 'E974:')
|
||||
|
||||
let lines =<< trim END
|
||||
VAR b = 0zDEADBEEF
|
||||
call remove(b, 1, [])
|
||||
END
|
||||
call CheckLegacyAndVim9Failure(lines, 'E745:')
|
||||
|
||||
let lines =<< trim END
|
||||
VAR b = 0zDEADBEEF
|
||||
call remove(test_null_blob(), 1, 2)
|
||||
@ -504,16 +486,6 @@ func Test_blob_index()
|
||||
call assert_equal(-1, index(test_null_blob(), 1))
|
||||
END
|
||||
call CheckLegacyAndVim9Success(lines)
|
||||
|
||||
let lines =<< trim END
|
||||
echo index(0z11110111, 0x11, [])
|
||||
END
|
||||
call CheckLegacyAndVim9Failure(lines, 'E745:')
|
||||
|
||||
let lines =<< trim END
|
||||
call index("asdf", 0)
|
||||
END
|
||||
call CheckLegacyAndVim9Failure(lines, 'E897:')
|
||||
endfunc
|
||||
|
||||
func Test_blob_insert()
|
||||
|
@ -1093,11 +1093,11 @@ func Test_gui_mouse_event()
|
||||
let &guioptions = save_guioptions
|
||||
|
||||
" Test invalid parameters for test_gui_mouse_event()
|
||||
call assert_fails('call test_gui_mouse_event("", 1, 2, 3, 4)', 'E474:')
|
||||
call assert_fails('call test_gui_mouse_event(0, "", 2, 3, 4)', 'E474:')
|
||||
call assert_fails('call test_gui_mouse_event(0, 1, "", 3, 4)', 'E474:')
|
||||
call assert_fails('call test_gui_mouse_event(0, 1, 2, "", 4)', 'E474:')
|
||||
call assert_fails('call test_gui_mouse_event(0, 1, 2, 3, "")', 'E474:')
|
||||
call assert_fails('call test_gui_mouse_event("", 1, 2, 3, 4)', 'E1210:')
|
||||
call assert_fails('call test_gui_mouse_event(0, "", 2, 3, 4)', 'E1210:')
|
||||
call assert_fails('call test_gui_mouse_event(0, 1, "", 3, 4)', 'E1210:')
|
||||
call assert_fails('call test_gui_mouse_event(0, 1, 2, "", 4)', 'E1210:')
|
||||
call assert_fails('call test_gui_mouse_event(0, 1, 2, 3, "")', 'E1210:')
|
||||
|
||||
bw!
|
||||
call test_override('no_query_mouse', 0)
|
||||
|
@ -270,18 +270,10 @@ enddef
|
||||
def Test_browse()
|
||||
CheckFeature browse
|
||||
|
||||
var lines =<< trim END
|
||||
browse(1, 2, 3, 4)
|
||||
END
|
||||
CheckDefExecAndScriptFailure(lines, 'E1174: String required for argument 2')
|
||||
lines =<< trim END
|
||||
browse(1, 'title', 3, 4)
|
||||
END
|
||||
CheckDefExecAndScriptFailure(lines, 'E1174: String required for argument 3')
|
||||
lines =<< trim END
|
||||
browse(1, 'title', 'dir', 4)
|
||||
END
|
||||
CheckDefExecAndScriptFailure(lines, 'E1174: String required for argument 4')
|
||||
CheckDefAndScriptFailure2(['browse(2, "title", "dir", "file")'], 'E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1')
|
||||
CheckDefAndScriptFailure2(['browse(true, 2, "dir", "file")'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2')
|
||||
CheckDefAndScriptFailure2(['browse(true, "title", 3, "file")'], 'E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3')
|
||||
CheckDefAndScriptFailure2(['browse(true, "title", "dir", 4)'], 'E1013: Argument 4: type mismatch, expected string but got number', 'E1174: String required for argument 4')
|
||||
enddef
|
||||
|
||||
def Test_browsedir()
|
||||
@ -330,6 +322,8 @@ def Test_bufnr()
|
||||
buf = bufnr('Xdummy', true)
|
||||
buf->assert_notequal(-1)
|
||||
exe 'bwipe! ' .. buf
|
||||
CheckDefAndScriptFailure2(['bufnr([1])'], 'E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['bufnr(1, 2)'], 'E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2')
|
||||
enddef
|
||||
|
||||
def Test_bufwinid()
|
||||
@ -379,22 +373,53 @@ enddef
|
||||
def Test_ch_canread()
|
||||
if !has('channel')
|
||||
CheckFeature channel
|
||||
else
|
||||
CheckDefFailure(['ch_canread(10)'], 'E1013: Argument 1: type mismatch, expected channel but got number')
|
||||
endif
|
||||
CheckDefFailure(['ch_canread(10)'], 'E1013: Argument 1: type mismatch, expected channel but got number')
|
||||
enddef
|
||||
|
||||
def Test_ch_close()
|
||||
if !has('channel')
|
||||
CheckFeature channel
|
||||
else
|
||||
CheckDefFailure(['ch_close("c")'], 'E1013: Argument 1: type mismatch, expected channel but got string')
|
||||
endif
|
||||
CheckDefFailure(['ch_close("c")'], 'E1013: Argument 1: type mismatch, expected channel but got string')
|
||||
enddef
|
||||
|
||||
def Test_ch_close_in()
|
||||
if !has('channel')
|
||||
CheckFeature channel
|
||||
else
|
||||
CheckDefFailure(['ch_close_in(true)'], 'E1013: Argument 1: type mismatch, expected channel but got bool')
|
||||
endif
|
||||
enddef
|
||||
|
||||
def Test_ch_evalexpr()
|
||||
if !has('channel')
|
||||
CheckFeature channel
|
||||
else
|
||||
CheckDefAndScriptFailure2(['ch_evalexpr(1, "a")'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E1218: Channel or Job required for argument 1')
|
||||
CheckDefAndScriptFailure2(['ch_evalexpr(test_null_channel(), 1, [])'], 'E1013: Argument 3: type mismatch, expected dict<any> but got list<unknown>', 'E1206: Dictionary required for argument 3')
|
||||
endif
|
||||
enddef
|
||||
|
||||
def Test_ch_evalraw()
|
||||
if !has('channel')
|
||||
CheckFeature channel
|
||||
else
|
||||
CheckDefAndScriptFailure2(['ch_evalraw(1, "")'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E1218: Channel or Job required for argument 1')
|
||||
CheckDefAndScriptFailure2(['ch_evalraw(test_null_channel(), 1)'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2')
|
||||
CheckDefAndScriptFailure2(['ch_evalraw(test_null_channel(), "", [])'], 'E1013: Argument 3: type mismatch, expected dict<any> but got list<unknown>', 'E1206: Dictionary required for argument 3')
|
||||
endif
|
||||
enddef
|
||||
|
||||
def Test_ch_getbufnr()
|
||||
if !has('channel')
|
||||
CheckFeature channel
|
||||
else
|
||||
CheckDefAndScriptFailure2(['ch_getbufnr(1, "a")'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E1218: Channel or Job required for argument 1')
|
||||
CheckDefAndScriptFailure2(['ch_getbufnr(test_null_channel(), 1)'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2')
|
||||
endif
|
||||
CheckDefFailure(['ch_close_in(true)'], 'E1013: Argument 1: type mismatch, expected channel but got bool')
|
||||
enddef
|
||||
|
||||
def Test_ch_getjob()
|
||||
@ -410,67 +435,94 @@ enddef
|
||||
def Test_ch_info()
|
||||
if !has('channel')
|
||||
CheckFeature channel
|
||||
else
|
||||
CheckDefFailure(['ch_info([1])'], 'E1013: Argument 1: type mismatch, expected channel but got list<number>')
|
||||
endif
|
||||
CheckDefFailure(['ch_info([1])'], 'E1013: Argument 1: type mismatch, expected channel but got list<number>')
|
||||
enddef
|
||||
|
||||
def Test_ch_logfile()
|
||||
if !has('channel')
|
||||
CheckFeature channel
|
||||
endif
|
||||
assert_fails('ch_logfile(true)', 'E1174:')
|
||||
assert_fails('ch_logfile("foo", true)', 'E1174:')
|
||||
else
|
||||
assert_fails('ch_logfile(true)', 'E1174:')
|
||||
assert_fails('ch_logfile("foo", true)', 'E1174:')
|
||||
|
||||
CheckDefAndScriptFailure2(['ch_logfile(1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['ch_logfile("a", true)'], 'E1013: Argument 2: type mismatch, expected string but got bool', 'E1174: String required for argument 2')
|
||||
CheckDefAndScriptFailure2(['ch_logfile(1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['ch_logfile("a", true)'], 'E1013: Argument 2: type mismatch, expected string but got bool', 'E1174: String required for argument 2')
|
||||
endif
|
||||
enddef
|
||||
|
||||
def Test_ch_open()
|
||||
if !has('channel')
|
||||
CheckFeature channel
|
||||
else
|
||||
CheckDefAndScriptFailure2(['ch_open({"a": 10}, "a")'], 'E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['ch_open("a", [1])'], 'E1013: Argument 2: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 2')
|
||||
endif
|
||||
CheckDefAndScriptFailure2(['ch_open({"a": 10}, "a")'], 'E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['ch_open("a", [1])'], 'E1013: Argument 2: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 2')
|
||||
enddef
|
||||
|
||||
def Test_ch_read()
|
||||
if !has('channel')
|
||||
CheckFeature channel
|
||||
else
|
||||
CheckDefAndScriptFailure2(['ch_read(1)'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E475: Invalid argument')
|
||||
CheckDefAndScriptFailure2(['ch_read(test_null_channel(), [])'], 'E1013: Argument 2: type mismatch, expected dict<any> but got list<unknown>', 'E715: Dictionary required')
|
||||
endif
|
||||
CheckDefAndScriptFailure2(['ch_read(1)'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E475: Invalid argument')
|
||||
CheckDefAndScriptFailure2(['ch_read(test_null_channel(), [])'], 'E1013: Argument 2: type mismatch, expected dict<any> but got list<unknown>', 'E715: Dictionary required')
|
||||
enddef
|
||||
|
||||
def Test_ch_readblob()
|
||||
if !has('channel')
|
||||
CheckFeature channel
|
||||
else
|
||||
CheckDefAndScriptFailure2(['ch_readblob(1)'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E475: Invalid argument')
|
||||
CheckDefAndScriptFailure2(['ch_readblob(test_null_channel(), [])'], 'E1013: Argument 2: type mismatch, expected dict<any> but got list<unknown>', 'E715: Dictionary required')
|
||||
endif
|
||||
CheckDefAndScriptFailure2(['ch_readblob(1)'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E475: Invalid argument')
|
||||
CheckDefAndScriptFailure2(['ch_readblob(test_null_channel(), [])'], 'E1013: Argument 2: type mismatch, expected dict<any> but got list<unknown>', 'E715: Dictionary required')
|
||||
enddef
|
||||
|
||||
def Test_ch_readraw()
|
||||
if !has('channel')
|
||||
CheckFeature channel
|
||||
else
|
||||
CheckDefAndScriptFailure2(['ch_readraw(1)'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E475: Invalid argument')
|
||||
CheckDefAndScriptFailure2(['ch_readraw(test_null_channel(), [])'], 'E1013: Argument 2: type mismatch, expected dict<any> but got list<unknown>', 'E715: Dictionary required')
|
||||
endif
|
||||
enddef
|
||||
|
||||
def Test_ch_sendexpr()
|
||||
if !has('channel')
|
||||
CheckFeature channel
|
||||
else
|
||||
CheckDefAndScriptFailure2(['ch_sendexpr(1, "a")'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E1218: Channel or Job required for argument 1')
|
||||
CheckDefAndScriptFailure2(['ch_sendexpr(test_null_channel(), 1, [])'], 'E1013: Argument 3: type mismatch, expected dict<any> but got list<unknown>', 'E1206: Dictionary required for argument 3')
|
||||
endif
|
||||
enddef
|
||||
|
||||
def Test_ch_sendraw()
|
||||
if !has('channel')
|
||||
CheckFeature channel
|
||||
else
|
||||
CheckDefAndScriptFailure2(['ch_sendraw(1, "")'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E1218: Channel or Job required for argument 1')
|
||||
CheckDefAndScriptFailure2(['ch_sendraw(test_null_channel(), 1)'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2')
|
||||
CheckDefAndScriptFailure2(['ch_sendraw(test_null_channel(), "", [])'], 'E1013: Argument 3: type mismatch, expected dict<any> but got list<unknown>', 'E1206: Dictionary required for argument 3')
|
||||
endif
|
||||
CheckDefAndScriptFailure2(['ch_readraw(1)'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E475: Invalid argument')
|
||||
CheckDefAndScriptFailure2(['ch_readraw(test_null_channel(), [])'], 'E1013: Argument 2: type mismatch, expected dict<any> but got list<unknown>', 'E715: Dictionary required')
|
||||
enddef
|
||||
|
||||
def Test_ch_setoptions()
|
||||
if !has('channel')
|
||||
CheckFeature channel
|
||||
else
|
||||
CheckDefAndScriptFailure2(['ch_setoptions(1, {})'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E475: Invalid argument')
|
||||
CheckDefFailure(['ch_setoptions(test_null_channel(), [])'], 'E1013: Argument 2: type mismatch, expected dict<any> but got list<unknown>')
|
||||
endif
|
||||
CheckDefAndScriptFailure2(['ch_setoptions(1, {})'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E475: Invalid argument')
|
||||
CheckDefFailure(['ch_setoptions(test_null_channel(), [])'], 'E1013: Argument 2: type mismatch, expected dict<any> but got list<unknown>')
|
||||
enddef
|
||||
|
||||
def Test_ch_status()
|
||||
if !has('channel')
|
||||
CheckFeature channel
|
||||
else
|
||||
CheckDefAndScriptFailure2(['ch_status(1)'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E475: Invalid argument')
|
||||
CheckDefAndScriptFailure2(['ch_status(test_null_channel(), [])'], 'E1013: Argument 2: type mismatch, expected dict<any> but got list<unknown>', 'E715: Dictionary required')
|
||||
endif
|
||||
CheckDefAndScriptFailure2(['ch_status(1)'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E475: Invalid argument')
|
||||
CheckDefAndScriptFailure2(['ch_status(test_null_channel(), [])'], 'E1013: Argument 2: type mismatch, expected dict<any> but got list<unknown>', 'E715: Dictionary required')
|
||||
enddef
|
||||
|
||||
def Test_char2nr()
|
||||
@ -538,6 +590,15 @@ def Test_col()
|
||||
bw!
|
||||
enddef
|
||||
|
||||
def Test_complete()
|
||||
CheckDefAndScriptFailure2(['complete("1", [])'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1')
|
||||
CheckDefAndScriptFailure2(['complete(1, {})'], 'E1013: Argument 2: type mismatch, expected list<any> but got dict<unknown>', 'E1211: List required for argument 2')
|
||||
enddef
|
||||
|
||||
def Test_complete_add()
|
||||
CheckDefAndScriptFailure2(['complete_add([])'], 'E1013: Argument 1: type mismatch, expected string but got list<unknown>', 'E1174: String required for argument 1')
|
||||
enddef
|
||||
|
||||
def Test_complete_info()
|
||||
CheckDefFailure(['complete_info("")'], 'E1013: Argument 1: type mismatch, expected list<string> but got string')
|
||||
CheckDefFailure(['complete_info({})'], 'E1013: Argument 1: type mismatch, expected list<string> but got dict<unknown>')
|
||||
@ -576,6 +637,12 @@ enddef
|
||||
def Test_count()
|
||||
count('ABC ABC ABC', 'b', true)->assert_equal(3)
|
||||
count('ABC ABC ABC', 'b', false)->assert_equal(0)
|
||||
CheckDefAndScriptFailure2(['count(10, 1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['count("a", [1], 2)'], 'E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3')
|
||||
CheckDefAndScriptFailure2(['count("a", [1], 0, "b")'], 'E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4')
|
||||
count([1, 2, 2, 3], 2)->assert_equal(2)
|
||||
count([1, 2, 2, 3], 2, false, 2)->assert_equal(1)
|
||||
count({a: 1.1, b: 2.2, c: 1.1}, 1.1)->assert_equal(2)
|
||||
enddef
|
||||
|
||||
def Test_cursor()
|
||||
@ -590,6 +657,9 @@ def Test_cursor()
|
||||
cursor('2', 1)
|
||||
END
|
||||
CheckDefExecAndScriptFailure(lines, 'E1209:')
|
||||
CheckDefAndScriptFailure2(['cursor(0z10, 1)'], 'E1013: Argument 1: type mismatch, expected number but got blob', 'E1210: Number required for argument 1')
|
||||
CheckDefAndScriptFailure2(['cursor(1, "2")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2')
|
||||
CheckDefAndScriptFailure2(['cursor(1, 2, "3")'], 'E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_debugbreak()
|
||||
@ -597,6 +667,10 @@ def Test_debugbreak()
|
||||
CheckDefFailure(['debugbreak("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
|
||||
enddef
|
||||
|
||||
def Test_deepcopy()
|
||||
CheckDefAndScriptFailure2(['deepcopy({}, 2)'], 'E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2')
|
||||
enddef
|
||||
|
||||
def Test_delete()
|
||||
var res: bool = delete('doesnotexist')
|
||||
assert_equal(true, res)
|
||||
@ -605,6 +679,12 @@ def Test_delete()
|
||||
CheckDefFailure(['delete("a", 10)'], 'E1013: Argument 2: type mismatch, expected string but got number')
|
||||
enddef
|
||||
|
||||
def Test_deletebufline()
|
||||
CheckDefAndScriptFailure2(['deletebufline([], 2)'], 'E1013: Argument 1: type mismatch, expected string but got list<unknown>', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['deletebufline("a", [])'], 'E1013: Argument 2: type mismatch, expected string but got list<unknown>', 'E1174: String required for argument 2')
|
||||
CheckDefAndScriptFailure2(['deletebufline("a", 2, 0z10)'], 'E1013: Argument 3: type mismatch, expected string but got blob', 'E1174: String required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_diff_filler()
|
||||
CheckDefFailure(['diff_filler([])'], 'E1013: Argument 1: type mismatch, expected string but got list<unknown>')
|
||||
CheckDefFailure(['diff_filler(true)'], 'E1013: Argument 1: type mismatch, expected string but got bool')
|
||||
@ -670,6 +750,9 @@ def Test_expand()
|
||||
split SomeFile
|
||||
expand('%', true, true)->assert_equal(['SomeFile'])
|
||||
close
|
||||
CheckDefAndScriptFailure2(['expand(1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['expand("a", 2)'], 'E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2')
|
||||
CheckDefAndScriptFailure2(['expand("a", true, 2)'], 'E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_expandcmd()
|
||||
@ -858,6 +941,8 @@ def Test_flattennew()
|
||||
echo flatten([1, 2, 3])
|
||||
END
|
||||
CheckDefAndScriptFailure(lines, 'E1158:')
|
||||
CheckDefAndScriptFailure2(['flattennew({})'], 'E1013: Argument 1: type mismatch, expected list<any> but got dict<unknown>', 'E1211: List required for argument 1')
|
||||
CheckDefAndScriptFailure2(['flattennew([], "1")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2')
|
||||
enddef
|
||||
|
||||
" Test for float functions argument type
|
||||
@ -1033,6 +1118,9 @@ def Test_getbufline()
|
||||
getbufline(-1, 1, '$')->assert_equal([])
|
||||
|
||||
bwipe!
|
||||
CheckDefAndScriptFailure2(['getbufline([], 2)'], 'E1013: Argument 1: type mismatch, expected string but got list<unknown>', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['getbufline("a", [])'], 'E1013: Argument 2: type mismatch, expected string but got list<unknown>', 'E1174: String required for argument 2')
|
||||
CheckDefAndScriptFailure2(['getbufline("a", 2, 0z10)'], 'E1013: Argument 3: type mismatch, expected string but got blob', 'E1174: String required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_getchangelist()
|
||||
@ -1062,24 +1150,14 @@ def Test_getcharstr()
|
||||
CheckDefAndScriptFailure2(['getcharstr("1")'], 'E1013: Argument 1: type mismatch, expected bool but got string', 'E1135: Using a String as a Bool')
|
||||
enddef
|
||||
|
||||
def Test_getenv()
|
||||
if getenv('does-not_exist') == ''
|
||||
assert_report('getenv() should return null')
|
||||
endif
|
||||
if getenv('does-not_exist') == null
|
||||
else
|
||||
assert_report('getenv() should return null')
|
||||
endif
|
||||
$SOMEENVVAR = 'some'
|
||||
assert_equal('some', getenv('SOMEENVVAR'))
|
||||
unlet $SOMEENVVAR
|
||||
enddef
|
||||
|
||||
def Test_getcompletion()
|
||||
set wildignore=*.vim,*~
|
||||
var l = getcompletion('run', 'file', true)
|
||||
l->assert_equal([])
|
||||
set wildignore&
|
||||
CheckDefAndScriptFailure2(['getcompletion(1, "b")'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['getcompletion("a", 2)'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2')
|
||||
CheckDefAndScriptFailure2(['getcompletion("a", "b", 2)'], 'E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_getcurpos()
|
||||
@ -1096,6 +1174,19 @@ def Test_getcwd()
|
||||
CheckDefFailure(['getcwd(1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
|
||||
enddef
|
||||
|
||||
def Test_getenv()
|
||||
if getenv('does-not_exist') == ''
|
||||
assert_report('getenv() should return null')
|
||||
endif
|
||||
if getenv('does-not_exist') == null
|
||||
else
|
||||
assert_report('getenv() should return null')
|
||||
endif
|
||||
$SOMEENVVAR = 'some'
|
||||
assert_equal('some', getenv('SOMEENVVAR'))
|
||||
unlet $SOMEENVVAR
|
||||
enddef
|
||||
|
||||
def Test_getfontname()
|
||||
CheckDefFailure(['getfontname(10)'], 'E1013: Argument 1: type mismatch, expected string but got number')
|
||||
enddef
|
||||
@ -1204,6 +1295,9 @@ def Test_getreg()
|
||||
setreg('a', lines)
|
||||
getreg('a', true, true)->assert_equal(lines)
|
||||
assert_fails('getreg("ab")', 'E1162:')
|
||||
CheckDefAndScriptFailure2(['getreg(1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['getreg(".", 2)'], 'E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2')
|
||||
CheckDefAndScriptFailure2(['getreg(".", 1, "b")'], 'E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_getreg_return_type()
|
||||
@ -1230,6 +1324,17 @@ def Test_gettabinfo()
|
||||
CheckDefFailure(['gettabinfo("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
|
||||
enddef
|
||||
|
||||
def Test_gettabvar()
|
||||
CheckDefAndScriptFailure2(['gettabvar("a", "b")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1')
|
||||
CheckDefAndScriptFailure2(['gettabvar(1, 2)'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2')
|
||||
enddef
|
||||
|
||||
def Test_gettabwinvar()
|
||||
CheckDefAndScriptFailure2(['gettabwinvar("a", 2, "c")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1')
|
||||
CheckDefAndScriptFailure2(['gettabwinvar(1, "b", "c", [])'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2')
|
||||
CheckDefAndScriptFailure2(['gettabwinvar(1, 1, 3, {})'], 'E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_gettagstack()
|
||||
CheckDefFailure(['gettagstack("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
|
||||
enddef
|
||||
@ -1247,8 +1352,17 @@ def Test_getwinpos()
|
||||
CheckDefFailure(['getwinpos("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
|
||||
enddef
|
||||
|
||||
def Test_getwinvar()
|
||||
CheckDefAndScriptFailure2(['getwinvar("a", "b")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1')
|
||||
CheckDefAndScriptFailure2(['getwinvar(1, 2)'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2')
|
||||
enddef
|
||||
|
||||
def Test_glob()
|
||||
glob('runtest.vim', true, true, true)->assert_equal(['runtest.vim'])
|
||||
CheckDefAndScriptFailure2(['glob(1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['glob("a", 2)'], 'E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2')
|
||||
CheckDefAndScriptFailure2(['glob("a", 1, "b")'], 'E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3')
|
||||
CheckDefAndScriptFailure2(['glob("a", 1, true, 2)'], 'E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4')
|
||||
enddef
|
||||
|
||||
def Test_glob2regpat()
|
||||
@ -1258,10 +1372,17 @@ enddef
|
||||
|
||||
def Test_globpath()
|
||||
globpath('.', 'runtest.vim', true, true, true)->assert_equal(['./runtest.vim'])
|
||||
CheckDefAndScriptFailure2(['globpath(1, "b")'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['globpath("a", 2)'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2')
|
||||
CheckDefAndScriptFailure2(['globpath("a", "b", "c")'], 'E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3')
|
||||
CheckDefAndScriptFailure2(['globpath("a", "b", true, "d")'], 'E1013: Argument 4: type mismatch, expected bool but got string', 'E1212: Bool required for argument 4')
|
||||
CheckDefAndScriptFailure2(['globpath("a", "b", true, false, "e")'], 'E1013: Argument 5: type mismatch, expected bool but got string', 'E1212: Bool required for argument 5')
|
||||
enddef
|
||||
|
||||
def Test_has()
|
||||
has('eval', true)->assert_equal(1)
|
||||
CheckDefAndScriptFailure2(['has(["a"])'], 'E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['has("a", "b")'], 'E1013: Argument 2: type mismatch, expected bool but got string', 'E1212: Bool required for argument 2')
|
||||
enddef
|
||||
|
||||
def Test_has_key()
|
||||
@ -1286,6 +1407,9 @@ def Test_hasmapto()
|
||||
iabbrev foo foobar
|
||||
hasmapto('foobar', 'i', true)->assert_equal(1)
|
||||
iunabbrev foo
|
||||
CheckDefAndScriptFailure2(['hasmapto(1, "b")'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['hasmapto("a", 2)'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2')
|
||||
CheckDefAndScriptFailure2(['hasmapto("a", "b", 2)'], 'E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_histadd()
|
||||
@ -1330,6 +1454,9 @@ enddef
|
||||
|
||||
def Test_index()
|
||||
index(['a', 'b', 'a', 'B'], 'b', 2, true)->assert_equal(3)
|
||||
CheckDefAndScriptFailure2(['index("a", "a")'], 'E1013: Argument 1: type mismatch, expected list<any> but got string', 'E1211: List required for argument 1')
|
||||
CheckDefAndScriptFailure2(['index([1], 1.1, "c")'], 'E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3')
|
||||
CheckDefAndScriptFailure2(['index(0z1020, [1], 1, 2)'], 'E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4')
|
||||
enddef
|
||||
|
||||
def Test_input()
|
||||
@ -1458,6 +1585,16 @@ def Test_job_info_return_type()
|
||||
endif
|
||||
enddef
|
||||
|
||||
def Test_job_setoptions()
|
||||
if !has('job')
|
||||
CheckFeature job
|
||||
else
|
||||
CheckDefAndScriptFailure2(['job_setoptions(test_null_channel(), {})'], 'E1013: Argument 1: type mismatch, expected job but got channel', 'E1219: Job required for argument 1')
|
||||
CheckDefAndScriptFailure2(['job_setoptions(test_null_job(), [])'], 'E1013: Argument 2: type mismatch, expected dict<any> but got list<unknown>', 'E1206: Dictionary required for argument 2')
|
||||
assert_equal('fail', job_status(test_null_job()))
|
||||
endif
|
||||
enddef
|
||||
|
||||
def Test_job_status()
|
||||
if !has('job')
|
||||
CheckFeature job
|
||||
@ -1467,6 +1604,20 @@ def Test_job_status()
|
||||
endif
|
||||
enddef
|
||||
|
||||
def Test_job_stop()
|
||||
if !has('job')
|
||||
CheckFeature job
|
||||
else
|
||||
CheckDefAndScriptFailure2(['job_stop("a")'], 'E1013: Argument 1: type mismatch, expected job but got string', 'E1219: Job required for argument 1')
|
||||
CheckDefAndScriptFailure2(['job_stop(test_null_job(), true)'], 'E1013: Argument 2: type mismatch, expected string but got bool', 'E1174: String required for argument 2')
|
||||
endif
|
||||
enddef
|
||||
|
||||
def Test_join()
|
||||
CheckDefAndScriptFailure2(['join("abc")'], 'E1013: Argument 1: type mismatch, expected list<any> but got string', 'E1211: List required for argument 1')
|
||||
CheckDefAndScriptFailure2(['join([], 2)'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2')
|
||||
enddef
|
||||
|
||||
def Test_js_decode()
|
||||
CheckDefFailure(['js_decode(10)'], 'E1013: Argument 1: type mismatch, expected string but got number')
|
||||
assert_equal([1, 2], js_decode('[1,2]'))
|
||||
@ -1512,6 +1663,11 @@ def Test_list2str_str2list_utf8()
|
||||
list2str(l, true)->assert_equal(s)
|
||||
enddef
|
||||
|
||||
def Test_list2str()
|
||||
CheckDefAndScriptFailure2(['list2str(".", true)'], 'E1013: Argument 1: type mismatch, expected list<number> but got string', 'E1211: List required for argument 1')
|
||||
CheckDefAndScriptFailure2(['list2str([1], 0z10)'], 'E1013: Argument 2: type mismatch, expected bool but got blob', 'E1212: Bool required for argument 2')
|
||||
enddef
|
||||
|
||||
def SID(): number
|
||||
return expand('<SID>')
|
||||
->matchstr('<SNR>\zs\d\+\ze_$')
|
||||
@ -1526,6 +1682,27 @@ def Test_listener_remove()
|
||||
CheckDefAndScriptFailure2(['listener_remove("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number')
|
||||
enddef
|
||||
|
||||
def Test_map_failure()
|
||||
CheckFeature job
|
||||
|
||||
var lines =<< trim END
|
||||
vim9script
|
||||
writefile([], 'Xtmpfile')
|
||||
silent e Xtmpfile
|
||||
var d = {[bufnr('%')]: {a: 0}}
|
||||
au BufReadPost * Func()
|
||||
def Func()
|
||||
if d->has_key('')
|
||||
endif
|
||||
eval d[expand('<abuf>')]->mapnew((_, v: dict<job>) => 0)
|
||||
enddef
|
||||
e
|
||||
END
|
||||
CheckScriptFailure(lines, 'E1013:')
|
||||
au! BufReadPost
|
||||
delete('Xtmpfile')
|
||||
enddef
|
||||
|
||||
def Test_map_function_arg()
|
||||
var lines =<< trim END
|
||||
def MapOne(i: number, v: string): string
|
||||
@ -1591,12 +1768,10 @@ def Test_maparg()
|
||||
rhs: 'bar',
|
||||
buffer: 0})
|
||||
unmap foo
|
||||
enddef
|
||||
|
||||
def Test_mapcheck()
|
||||
iabbrev foo foobar
|
||||
mapcheck('foo', 'i', true)->assert_equal('foobar')
|
||||
iunabbrev foo
|
||||
CheckDefAndScriptFailure2(['maparg(1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['maparg("a", 2)'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2')
|
||||
CheckDefAndScriptFailure2(['maparg("a", "b", 2)'], 'E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3')
|
||||
CheckDefAndScriptFailure2(['maparg("a", "b", true, 2)'], 'E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4')
|
||||
enddef
|
||||
|
||||
def Test_maparg_mapset()
|
||||
@ -1607,25 +1782,19 @@ def Test_maparg_mapset()
|
||||
nunmap <F3>
|
||||
enddef
|
||||
|
||||
def Test_map_failure()
|
||||
CheckFeature job
|
||||
def Test_mapcheck()
|
||||
iabbrev foo foobar
|
||||
mapcheck('foo', 'i', true)->assert_equal('foobar')
|
||||
iunabbrev foo
|
||||
CheckDefAndScriptFailure2(['mapcheck(1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['mapcheck("a", 2)'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2')
|
||||
CheckDefAndScriptFailure2(['mapcheck("a", "b", 2)'], 'E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3')
|
||||
enddef
|
||||
|
||||
var lines =<< trim END
|
||||
vim9script
|
||||
writefile([], 'Xtmpfile')
|
||||
silent e Xtmpfile
|
||||
var d = {[bufnr('%')]: {a: 0}}
|
||||
au BufReadPost * Func()
|
||||
def Func()
|
||||
if d->has_key('')
|
||||
endif
|
||||
eval d[expand('<abuf>')]->mapnew((_, v: dict<job>) => 0)
|
||||
enddef
|
||||
e
|
||||
END
|
||||
CheckScriptFailure(lines, 'E1013:')
|
||||
au! BufReadPost
|
||||
delete('Xtmpfile')
|
||||
def Test_mapset()
|
||||
CheckDefAndScriptFailure2(['mapset(1, true, {})'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['mapset("a", 2, {})'], 'E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2')
|
||||
CheckDefAndScriptFailure2(['mapset("a", false, [])'], 'E1013: Argument 3: type mismatch, expected dict<any> but got list<unknown>', 'E1206: Dictionary required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_match()
|
||||
@ -1668,6 +1837,18 @@ def Test_matchend()
|
||||
assert_equal(5, matchend(['a', 'b', 'c', 'b', 'd', 'b'], 'b', 2, 2))
|
||||
enddef
|
||||
|
||||
def Test_matchfuzzy()
|
||||
CheckDefAndScriptFailure2(['matchfuzzy({}, "p")'], 'E1013: Argument 1: type mismatch, expected list<any> but got dict<unknown>', 'E1211: List required for argument 1')
|
||||
CheckDefAndScriptFailure2(['matchfuzzy([], 1)'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2')
|
||||
CheckDefAndScriptFailure2(['matchfuzzy([], "a", [])'], 'E1013: Argument 3: type mismatch, expected dict<any> but got list<unknown>', 'E1206: Dictionary required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_matchfuzzypos()
|
||||
CheckDefAndScriptFailure2(['matchfuzzypos({}, "p")'], 'E1013: Argument 1: type mismatch, expected list<any> but got dict<unknown>', 'E1211: List required for argument 1')
|
||||
CheckDefAndScriptFailure2(['matchfuzzypos([], 1)'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2')
|
||||
CheckDefAndScriptFailure2(['matchfuzzypos([], "a", [])'], 'E1013: Argument 3: type mismatch, expected dict<any> but got list<unknown>', 'E1206: Dictionary required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_matchlist()
|
||||
CheckDefAndScriptFailure2(['matchlist(0z12, "p")'], 'E1013: Argument 1: type mismatch, expected string but got blob', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['matchlist(["s"], [2])'], 'E1013: Argument 2: type mismatch, expected string but got list<number>', 'E1174: String required for argument 2')
|
||||
@ -1781,6 +1962,8 @@ enddef
|
||||
|
||||
def Test_nr2char()
|
||||
nr2char(97, true)->assert_equal('a')
|
||||
CheckDefAndScriptFailure2(['nr2char("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1')
|
||||
CheckDefAndScriptFailure2(['nr2char(1, "a")'], 'E1013: Argument 2: type mismatch, expected bool but got string', 'E1212: Bool required for argument 2')
|
||||
enddef
|
||||
|
||||
def Test_or()
|
||||
@ -1906,9 +2089,22 @@ enddef
|
||||
def Test_prompt_setprompt()
|
||||
if !has('channel')
|
||||
CheckFeature channel
|
||||
else
|
||||
CheckDefAndScriptFailure2(['prompt_setprompt([], "p")'], 'E1013: Argument 1: type mismatch, expected string but got list<unknown>', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['prompt_setprompt(1, [])'], 'E1013: Argument 2: type mismatch, expected string but got list<unknown>', 'E1174: String required for argument 2')
|
||||
endif
|
||||
CheckDefAndScriptFailure2(['prompt_setprompt([], "p")'], 'E1013: Argument 1: type mismatch, expected string but got list<unknown>', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['prompt_setprompt(1, [])'], 'E1013: Argument 2: type mismatch, expected string but got list<unknown>', 'E1174: String required for argument 2')
|
||||
enddef
|
||||
|
||||
def Test_prop_add()
|
||||
CheckDefAndScriptFailure2(['prop_add("a", 2, {})'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1')
|
||||
CheckDefAndScriptFailure2(['prop_add(1, "b", {})'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2')
|
||||
CheckDefAndScriptFailure2(['prop_add(1, 2, [])'], 'E1013: Argument 3: type mismatch, expected dict<any> but got list<unknown>', 'E1206: Dictionary required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_prop_clear()
|
||||
CheckDefAndScriptFailure2(['prop_clear("a")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1')
|
||||
CheckDefAndScriptFailure2(['prop_clear(1, "b")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2')
|
||||
CheckDefAndScriptFailure2(['prop_clear(1, 2, [])'], 'E1013: Argument 3: type mismatch, expected dict<any> but got list<unknown>', 'E1206: Dictionary required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_prop_find()
|
||||
@ -1922,6 +2118,12 @@ def Test_prop_list()
|
||||
CheckDefAndScriptFailure2(['prop_list(1, [])'], 'E1013: Argument 2: type mismatch, expected dict<any> but got list<unknown>', 'E1206: Dictionary required for argument 2')
|
||||
enddef
|
||||
|
||||
def Test_prop_remove()
|
||||
CheckDefAndScriptFailure2(['prop_remove([])'], 'E1013: Argument 1: type mismatch, expected dict<any> but got list<unknown>', 'E1206: Dictionary required for argument 1')
|
||||
CheckDefAndScriptFailure2(['prop_remove({}, "a")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2')
|
||||
CheckDefAndScriptFailure2(['prop_remove({}, 1, "b")'], 'E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_prop_type_add()
|
||||
CheckDefAndScriptFailure2(['prop_type_add({"a": 10}, "b")'], 'E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E731: Using a Dictionary as a String')
|
||||
CheckDefAndScriptFailure2(['prop_type_add("a", "b")'], 'E1013: Argument 2: type mismatch, expected dict<any> but got string', 'E715: Dictionary required')
|
||||
@ -2053,6 +2255,15 @@ def Test_reltimestr()
|
||||
assert_true(type(reltimestr(reltime())) == v:t_string)
|
||||
enddef
|
||||
|
||||
def Test_remote_expr()
|
||||
CheckFeature clientserver
|
||||
CheckEnv DISPLAY
|
||||
CheckDefAndScriptFailure2(['remote_expr(1, "b")'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['remote_expr("a", 2)'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2')
|
||||
CheckDefAndScriptFailure2(['remote_expr("a", "b", 3)'], 'E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3')
|
||||
CheckDefAndScriptFailure2(['remote_expr("a", "b", "c", "d")'], 'E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4')
|
||||
enddef
|
||||
|
||||
def Test_remote_foreground()
|
||||
CheckFeature clientserver
|
||||
# remote_foreground() doesn't fail on MS-Windows
|
||||
@ -2077,6 +2288,14 @@ def Test_remote_read()
|
||||
CheckDefAndScriptFailure2(['remote_read("a", "x")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2')
|
||||
enddef
|
||||
|
||||
def Test_remote_send()
|
||||
CheckFeature clientserver
|
||||
CheckEnv DISPLAY
|
||||
CheckDefAndScriptFailure2(['remote_send(1, "b")'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['remote_send("a", 2)'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2')
|
||||
CheckDefAndScriptFailure2(['remote_send("a", "b", 3)'], 'E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_remote_startserver()
|
||||
CheckFeature clientserver
|
||||
CheckEnv DISPLAY
|
||||
@ -2089,6 +2308,31 @@ def Test_remove_const_list()
|
||||
assert_equal([3, 4], l)
|
||||
enddef
|
||||
|
||||
def Test_remove()
|
||||
CheckDefAndScriptFailure2(['remove("a", 1)'], 'E1013: Argument 1: type mismatch, expected list<any> but got string', 'E896: Argument of remove() must be a List, Dictionary or Blob')
|
||||
CheckDefAndScriptFailure2(['remove([], "b")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2')
|
||||
CheckDefAndScriptFailure2(['remove([], 1, "c")'], 'E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3')
|
||||
CheckDefAndScriptFailure2(['remove({}, 1.1)'], 'E1013: Argument 2: type mismatch, expected string but got float', 'E1174: String required for argument 2')
|
||||
CheckDefAndScriptFailure2(['remove(0z10, "b")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2')
|
||||
CheckDefAndScriptFailure2(['remove(0z20, 1, "c")'], 'E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3')
|
||||
var l: any = [1, 2, 3, 4]
|
||||
remove(l, 1)
|
||||
assert_equal([1, 3, 4], l)
|
||||
remove(l, 0, 1)
|
||||
assert_equal([4], l)
|
||||
var b: any = 0z1234.5678.90
|
||||
remove(b, 1)
|
||||
assert_equal(0z1256.7890, b)
|
||||
remove(b, 1, 2)
|
||||
assert_equal(0z1290, b)
|
||||
var d: any = {a: 10, b: 20, c: 30}
|
||||
remove(d, 'b')
|
||||
assert_equal({a: 10, c: 30}, d)
|
||||
var d2: any = {1: 'a', 2: 'b', 3: 'c'}
|
||||
remove(d2, 2)
|
||||
assert_equal({1: 'a', 3: 'c'}, d2)
|
||||
enddef
|
||||
|
||||
def Test_remove_return_type()
|
||||
var l = remove({one: [1, 2], two: [3, 4]}, 'one')
|
||||
var res = 0
|
||||
@ -2202,6 +2446,13 @@ def Test_searchcount()
|
||||
CheckDefAndScriptFailure2(['searchcount([1])'], 'E1013: Argument 1: type mismatch, expected dict<any> but got list<number>', 'E715: Dictionary required')
|
||||
enddef
|
||||
|
||||
def Test_searchdecl()
|
||||
searchdecl('blah', true, true)->assert_equal(1)
|
||||
CheckDefAndScriptFailure2(['searchdecl(1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['searchdecl("a", 2)'], 'E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2')
|
||||
CheckDefAndScriptFailure2(['searchdecl("a", true, 2)'], 'E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_searchpair()
|
||||
new
|
||||
setline(1, "here { and } there")
|
||||
@ -2247,6 +2498,11 @@ def Test_server2client()
|
||||
CheckDefAndScriptFailure2(['server2client("a", 10)'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E573: Invalid server id used:')
|
||||
enddef
|
||||
|
||||
def Test_shellescape()
|
||||
CheckDefAndScriptFailure2(['shellescape(1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['shellescape("a", 2)'], 'E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2')
|
||||
enddef
|
||||
|
||||
def Test_set_get_bufline()
|
||||
# similar to Test_setbufline_getbufline()
|
||||
var lines =<< trim END
|
||||
@ -2297,10 +2553,6 @@ def Test_set_get_bufline()
|
||||
CheckDefAndScriptSuccess(lines)
|
||||
enddef
|
||||
|
||||
def Test_searchdecl()
|
||||
searchdecl('blah', true, true)->assert_equal(1)
|
||||
enddef
|
||||
|
||||
def Test_setbufvar()
|
||||
setbufvar(bufnr('%'), '&syntax', 'vim')
|
||||
&syntax->assert_equal('vim')
|
||||
@ -2326,23 +2578,6 @@ def Test_setbufvar()
|
||||
getbufvar('%', 'myvar')->assert_equal(123)
|
||||
enddef
|
||||
|
||||
def Test_setcharsearch()
|
||||
CheckDefFailure(['setcharsearch("x")'], 'E1013: Argument 1: type mismatch, expected dict<any> but got string')
|
||||
CheckDefFailure(['setcharsearch([])'], 'E1013: Argument 1: type mismatch, expected dict<any> but got list<unknown>')
|
||||
var d: dict<any> = {char: 'x', forward: 1, until: 1}
|
||||
setcharsearch(d)
|
||||
assert_equal(d, getcharsearch())
|
||||
enddef
|
||||
|
||||
def Test_setcmdpos()
|
||||
CheckDefFailure(['setcmdpos("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
|
||||
enddef
|
||||
|
||||
def Test_setfperm()
|
||||
CheckDefFailure(['setfperm(1, "b")'], 'E1013: Argument 1: type mismatch, expected string but got number')
|
||||
CheckDefFailure(['setfperm("a", 0z10)'], 'E1013: Argument 2: type mismatch, expected string but got blob')
|
||||
enddef
|
||||
|
||||
def Test_setbufline()
|
||||
new
|
||||
var bnum = bufnr('%')
|
||||
@ -2364,6 +2599,35 @@ def Test_setcellwidths()
|
||||
CheckDefAndScriptFailure2(['setcellwidths({"a": 10})'], 'E1013: Argument 1: type mismatch, expected list<any> but got dict<number>', 'E714: List required')
|
||||
enddef
|
||||
|
||||
def Test_setcharpos()
|
||||
CheckDefAndScriptFailure2(['setcharpos(1, [])'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||
CheckDefFailure(['setcharpos(".", ["a"])'], 'E1013: Argument 2: type mismatch, expected list<number> but got list<string>')
|
||||
CheckDefAndScriptFailure2(['setcharpos(".", 1)'], 'E1013: Argument 2: type mismatch, expected list<number> but got number', 'E1211: List required for argument 2')
|
||||
enddef
|
||||
|
||||
def Test_setcharsearch()
|
||||
CheckDefFailure(['setcharsearch("x")'], 'E1013: Argument 1: type mismatch, expected dict<any> but got string')
|
||||
CheckDefFailure(['setcharsearch([])'], 'E1013: Argument 1: type mismatch, expected dict<any> but got list<unknown>')
|
||||
var d: dict<any> = {char: 'x', forward: 1, until: 1}
|
||||
setcharsearch(d)
|
||||
assert_equal(d, getcharsearch())
|
||||
enddef
|
||||
|
||||
def Test_setcmdpos()
|
||||
CheckDefFailure(['setcmdpos("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
|
||||
enddef
|
||||
|
||||
def Test_setcursorcharpos()
|
||||
CheckDefAndScriptFailure2(['setcursorcharpos(0z10, 1)'], 'E1013: Argument 1: type mismatch, expected number but got blob', 'E1210: Number required for argument 1')
|
||||
CheckDefAndScriptFailure2(['setcursorcharpos(1, "2")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2')
|
||||
CheckDefAndScriptFailure2(['setcursorcharpos(1, 2, "3")'], 'E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_setfperm()
|
||||
CheckDefFailure(['setfperm(1, "b")'], 'E1013: Argument 1: type mismatch, expected string but got number')
|
||||
CheckDefFailure(['setfperm("a", 0z10)'], 'E1013: Argument 2: type mismatch, expected string but got blob')
|
||||
enddef
|
||||
|
||||
def Test_setline()
|
||||
new
|
||||
setline(1, range(1, 4))
|
||||
@ -2383,6 +2647,27 @@ def Test_setloclist()
|
||||
var what = {items: items}
|
||||
setqflist([], ' ', what)
|
||||
setloclist(0, [], ' ', what)
|
||||
CheckDefAndScriptFailure2(['setloclist("1", [])'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1')
|
||||
CheckDefAndScriptFailure2(['setloclist(1, 2)'], 'E1013: Argument 2: type mismatch, expected list<any> but got number', 'E1211: List required for argument 2')
|
||||
CheckDefAndScriptFailure2(['setloclist(1, [], 3)'], 'E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3')
|
||||
CheckDefAndScriptFailure2(['setloclist(1, [], "a", [])'], 'E1013: Argument 4: type mismatch, expected dict<any> but got list<unknown>', 'E1206: Dictionary required for argument 4')
|
||||
enddef
|
||||
|
||||
def Test_setmatches()
|
||||
CheckDefAndScriptFailure2(['setmatches({})'], 'E1013: Argument 1: type mismatch, expected list<any> but got dict<unknown>', 'E1211: List required for argument 1')
|
||||
CheckDefAndScriptFailure2(['setmatches([], "1")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2')
|
||||
enddef
|
||||
|
||||
def Test_setpos()
|
||||
CheckDefAndScriptFailure2(['setpos(1, [])'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||
CheckDefFailure(['setpos(".", ["a"])'], 'E1013: Argument 2: type mismatch, expected list<number> but got list<string>')
|
||||
CheckDefAndScriptFailure2(['setpos(".", 1)'], 'E1013: Argument 2: type mismatch, expected list<number> but got number', 'E1211: List required for argument 2')
|
||||
enddef
|
||||
|
||||
def Test_setqflist()
|
||||
CheckDefAndScriptFailure2(['setqflist(1, "")'], 'E1013: Argument 1: type mismatch, expected list<any> but got number', 'E1211: List required for argument 1')
|
||||
CheckDefAndScriptFailure2(['setqflist([], 2)'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2')
|
||||
CheckDefAndScriptFailure2(['setqflist([], "", [])'], 'E1013: Argument 3: type mismatch, expected dict<any> but got list<unknown>', 'E1206: Dictionary required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_setreg()
|
||||
@ -2393,6 +2678,28 @@ def Test_setreg()
|
||||
assert_fails('setreg("ab", 0)', 'E1162:')
|
||||
enddef
|
||||
|
||||
def Test_settabvar()
|
||||
CheckDefAndScriptFailure2(['settabvar("a", "b", 1)'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1')
|
||||
CheckDefAndScriptFailure2(['settabvar(1, 2, "c")'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2')
|
||||
enddef
|
||||
|
||||
def Test_settabwinvar()
|
||||
CheckDefAndScriptFailure2(['settabwinvar("a", 2, "c", true)'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1')
|
||||
CheckDefAndScriptFailure2(['settabwinvar(1, "b", "c", [])'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2')
|
||||
CheckDefAndScriptFailure2(['settabwinvar(1, 1, 3, {})'], 'E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_settagstack()
|
||||
CheckDefAndScriptFailure2(['settagstack(true, {})'], 'E1013: Argument 1: type mismatch, expected number but got bool', 'E1210: Number required for argument 1')
|
||||
CheckDefAndScriptFailure2(['settagstack(1, [1])'], 'E1013: Argument 2: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 2')
|
||||
CheckDefAndScriptFailure2(['settagstack(1, {}, 2)'], 'E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_setwinvar()
|
||||
CheckDefAndScriptFailure2(['setwinvar("a", "b", 1)'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1')
|
||||
CheckDefAndScriptFailure2(['setwinvar(1, 2, "c")'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2')
|
||||
enddef
|
||||
|
||||
def Test_sha256()
|
||||
CheckDefFailure(['sha256(100)'], 'E1013: Argument 1: type mismatch, expected string but got number')
|
||||
CheckDefFailure(['sha256(0zABCD)'], 'E1013: Argument 1: type mismatch, expected string but got blob')
|
||||
@ -2414,6 +2721,12 @@ def Test_sign_getdefined()
|
||||
CheckDefAndScriptFailure2(['sign_getdefined(2)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||
enddef
|
||||
|
||||
def Test_sign_getplaced()
|
||||
CheckDefAndScriptFailure2(['sign_getplaced(["x"])'], 'E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['sign_getplaced(1, ["a"])'], 'E1013: Argument 2: type mismatch, expected dict<any> but got list<string>', 'E1206: Dictionary required for argument 2')
|
||||
CheckDefAndScriptFailure2(['sign_getplaced("a", 1.1)'], 'E1013: Argument 2: type mismatch, expected dict<any> but got float', 'E1206: Dictionary required for argument 2')
|
||||
enddef
|
||||
|
||||
def Test_sign_placelist()
|
||||
CheckDefAndScriptFailure2(['sign_placelist("x")'], 'E1013: Argument 1: type mismatch, expected list<any> but got string', 'E714: List required')
|
||||
CheckDefAndScriptFailure2(['sign_placelist({"a": 10})'], 'E1013: Argument 1: type mismatch, expected list<any> but got dict<number>', 'E714: List required')
|
||||
@ -2461,6 +2774,9 @@ def Test_slice()
|
||||
assert_equal(0z11, slice(0z001122334455, 1, -4))
|
||||
assert_equal(0z, slice(0z001122334455, 1, -5))
|
||||
assert_equal(0z, slice(0z001122334455, 1, -6))
|
||||
CheckDefAndScriptFailure2(['slice({"a": 10}, 1)'], 'E1013: Argument 1: type mismatch, expected list<any> but got dict<number>', 'E1211: List required for argument 1')
|
||||
CheckDefAndScriptFailure2(['slice([1, 2, 3], "b")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2')
|
||||
CheckDefAndScriptFailure2(['slice("abc", 1, "c")'], 'E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_spellsuggest()
|
||||
@ -2469,6 +2785,9 @@ def Test_spellsuggest()
|
||||
else
|
||||
spellsuggest('marrch', 1, true)->assert_equal(['March'])
|
||||
endif
|
||||
CheckDefAndScriptFailure2(['spellsuggest(1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['spellsuggest("a", "b")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2')
|
||||
CheckDefAndScriptFailure2(['spellsuggest("a", 1, 0z01)'], 'E1013: Argument 3: type mismatch, expected bool but got blob', 'E1212: Bool required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_sound_stop()
|
||||
@ -2508,6 +2827,9 @@ enddef
|
||||
|
||||
def Test_split()
|
||||
split(' aa bb ', '\W\+', true)->assert_equal(['', 'aa', 'bb', ''])
|
||||
CheckDefAndScriptFailure2(['split(1, "b")'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['split("a", 2)'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2')
|
||||
CheckDefAndScriptFailure2(['split("a", "b", 2)'], 'E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_srand()
|
||||
@ -2557,6 +2879,13 @@ def Test_strcharlen()
|
||||
strcharlen(99)->assert_equal(2)
|
||||
enddef
|
||||
|
||||
def Test_strcharpart()
|
||||
CheckDefAndScriptFailure2(['strcharpart(1, 2)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['strcharpart("a", "b")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2')
|
||||
CheckDefAndScriptFailure2(['strcharpart("a", 1, "c")'], 'E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3')
|
||||
CheckDefAndScriptFailure2(['strcharpart("a", 1, 1, 2)'], 'E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4')
|
||||
enddef
|
||||
|
||||
def Test_strchars()
|
||||
strchars("A\u20dd", true)->assert_equal(1)
|
||||
CheckDefAndScriptFailure2(['strchars(10)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||
@ -2593,6 +2922,13 @@ def Test_strlen()
|
||||
strlen(99)->assert_equal(2)
|
||||
enddef
|
||||
|
||||
def Test_strpart()
|
||||
CheckDefAndScriptFailure2(['strpart(1, 2)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['strpart("a", "b")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2')
|
||||
CheckDefAndScriptFailure2(['strpart("a", 1, "c")'], 'E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3')
|
||||
CheckDefAndScriptFailure2(['strpart("a", 1, 1, 2)'], 'E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4')
|
||||
enddef
|
||||
|
||||
def Test_strptime()
|
||||
CheckFunction strptime
|
||||
CheckDefFailure(['strptime(10, "2021")'], 'E1013: Argument 1: type mismatch, expected string but got number')
|
||||
@ -2626,6 +2962,8 @@ def Test_submatch()
|
||||
var actual = substitute('A123456789', pat, Rep, '')
|
||||
var expected = "[['A123456789'], ['1'], ['2'], ['3'], ['4'], ['5'], ['6'], ['7'], ['8'], ['9']]"
|
||||
actual->assert_equal(expected)
|
||||
CheckDefAndScriptFailure2(['submatch("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1')
|
||||
CheckDefAndScriptFailure2(['submatch(1, "a")'], 'E1013: Argument 2: type mismatch, expected bool but got string', 'E1212: Bool required for argument 2')
|
||||
enddef
|
||||
|
||||
def Test_substitute()
|
||||
@ -2653,6 +2991,9 @@ def Test_synID()
|
||||
setline(1, "text")
|
||||
synID(1, 1, true)->assert_equal(0)
|
||||
bwipe!
|
||||
CheckDefAndScriptFailure2(['synID(0z10, 1, true)'], 'E1013: Argument 1: type mismatch, expected string but got blob', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['synID("a", true, false)'], 'E1013: Argument 2: type mismatch, expected number but got bool', 'E1210: Number required for argument 2')
|
||||
CheckDefAndScriptFailure2(['synID(1, 1, 2)'], 'E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_synIDtrans()
|
||||
@ -2753,6 +3094,8 @@ def Test_term_gettty()
|
||||
term_gettty(buf, true)->assert_notequal('')
|
||||
StopShellInTerminal(buf)
|
||||
endif
|
||||
CheckDefAndScriptFailure2(['term_gettty([1])'], 'E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['term_gettty(1, 2)'], 'E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2')
|
||||
enddef
|
||||
|
||||
def Test_term_sendkeys()
|
||||
@ -2761,6 +3104,12 @@ def Test_term_sendkeys()
|
||||
CheckDefAndScriptFailure2(['term_sendkeys(1, [])'], 'E1013: Argument 2: type mismatch, expected string but got list<unknown>', 'E1174: String required for argument 2')
|
||||
enddef
|
||||
|
||||
def Test_term_setansicolors()
|
||||
CheckRunVimInTerminal
|
||||
CheckDefAndScriptFailure2(['term_setansicolors([], "p")'], 'E1013: Argument 1: type mismatch, expected string but got list<unknown>', 'E1174: String required for argument 1')
|
||||
CheckDefAndScriptFailure2(['term_setansicolors(10, {})'], 'E1013: Argument 2: type mismatch, expected list<any> but got dict<unknown>', 'E1211: List required for argument 2')
|
||||
enddef
|
||||
|
||||
def Test_term_setapi()
|
||||
CheckRunVimInTerminal
|
||||
CheckDefAndScriptFailure2(['term_setapi([], "p")'], 'E1013: Argument 1: type mismatch, expected string but got list<unknown>', 'E1174: String required for argument 1')
|
||||
@ -2811,6 +3160,15 @@ def Test_test_getvalue()
|
||||
CheckDefAndScriptFailure2(['test_getvalue(1.1)'], 'E1013: Argument 1: type mismatch, expected string but got float', 'E474: Invalid argument')
|
||||
enddef
|
||||
|
||||
def Test_test_gui_mouse_event()
|
||||
CheckGui
|
||||
CheckDefAndScriptFailure2(['test_gui_mouse_event(1.1, 1, 1, 1, 1)'], 'E1013: Argument 1: type mismatch, expected number but got float', 'E1210: Number required for argument 1')
|
||||
CheckDefAndScriptFailure2(['test_gui_mouse_event(1, "1", 1, 1, 1)'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2')
|
||||
CheckDefAndScriptFailure2(['test_gui_mouse_event(1, 1, "1", 1, 1)'], 'E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3')
|
||||
CheckDefAndScriptFailure2(['test_gui_mouse_event(1, 1, 1, "1", 1)'], 'E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4')
|
||||
CheckDefAndScriptFailure2(['test_gui_mouse_event(1, 1, 1, 1, "1")'], 'E1013: Argument 5: type mismatch, expected number but got string', 'E1210: Number required for argument 5')
|
||||
enddef
|
||||
|
||||
def Test_test_ignore_error()
|
||||
CheckDefAndScriptFailure2(['test_ignore_error([])'], 'E1013: Argument 1: type mismatch, expected string but got list<unknown>', 'E474: Invalid argument')
|
||||
test_ignore_error('RESET')
|
||||
@ -2845,6 +3203,11 @@ def Test_timer_info()
|
||||
assert_equal([], timer_info())
|
||||
enddef
|
||||
|
||||
def Test_timer_pause()
|
||||
CheckDefAndScriptFailure2(['timer_pause("x", 1)'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1')
|
||||
CheckDefAndScriptFailure2(['timer_pause(1, "a")'], 'E1013: Argument 2: type mismatch, expected bool but got string', 'E1212: Bool required for argument 2')
|
||||
enddef
|
||||
|
||||
def Test_timer_paused()
|
||||
var id = timer_start(50, () => 0)
|
||||
timer_pause(id, true)
|
||||
@ -2955,6 +3318,9 @@ def Test_win_splitmove()
|
||||
split
|
||||
win_splitmove(1, 2, {vertical: true, rightbelow: true})
|
||||
close
|
||||
CheckDefAndScriptFailure2(['win_splitmove("a", 2)'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1')
|
||||
CheckDefAndScriptFailure2(['win_splitmove(1, "b")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2')
|
||||
CheckDefAndScriptFailure2(['win_splitmove(1, 2, [])'], 'E1013: Argument 3: type mismatch, expected dict<any> but got list<unknown>', 'E1206: Dictionary required for argument 3')
|
||||
enddef
|
||||
|
||||
def Test_winbufnr()
|
||||
|
@ -1246,15 +1246,12 @@ f_test_gui_mouse_event(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
|
||||
int repeated_click;
|
||||
int_u mods;
|
||||
|
||||
if (argvars[0].v_type != VAR_NUMBER
|
||||
|| (argvars[1].v_type) != VAR_NUMBER
|
||||
|| (argvars[2].v_type) != VAR_NUMBER
|
||||
|| (argvars[3].v_type) != VAR_NUMBER
|
||||
|| (argvars[4].v_type) != VAR_NUMBER)
|
||||
{
|
||||
emsg(_(e_invarg));
|
||||
if (check_for_number_arg(argvars, 0) == FAIL
|
||||
|| check_for_number_arg(argvars, 1) == FAIL
|
||||
|| check_for_number_arg(argvars, 2) == FAIL
|
||||
|| check_for_number_arg(argvars, 3) == FAIL
|
||||
|| check_for_number_arg(argvars, 4) == FAIL)
|
||||
return;
|
||||
}
|
||||
|
||||
button = tv_get_number(&argvars[0]);
|
||||
row = tv_get_number(&argvars[1]);
|
||||
|
@ -158,6 +158,12 @@ f_prop_add(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
linenr_T start_lnum;
|
||||
colnr_T start_col;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_number_arg(argvars, 0) == FAIL
|
||||
|| check_for_number_arg(argvars, 1) == FAIL
|
||||
|| check_for_dict_arg(argvars, 2) == FAIL))
|
||||
return;
|
||||
|
||||
start_lnum = tv_get_number(&argvars[0]);
|
||||
start_col = tv_get_number(&argvars[1]);
|
||||
if (start_col < 1)
|
||||
@ -532,12 +538,21 @@ text_prop_type_by_id(buf_T *buf, int id)
|
||||
void
|
||||
f_prop_clear(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
{
|
||||
linenr_T start = tv_get_number(&argvars[0]);
|
||||
linenr_T end = start;
|
||||
linenr_T start;
|
||||
linenr_T end;
|
||||
linenr_T lnum;
|
||||
buf_T *buf = curbuf;
|
||||
int did_clear = FALSE;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_number_arg(argvars, 0) == FAIL
|
||||
|| check_for_opt_number_arg(argvars, 1) == FAIL
|
||||
|| (argvars[1].v_type != VAR_UNKNOWN
|
||||
&& check_for_opt_dict_arg(argvars, 2) == FAIL)))
|
||||
return;
|
||||
|
||||
start = tv_get_number(&argvars[0]);
|
||||
end = start;
|
||||
if (argvars[1].v_type != VAR_UNKNOWN)
|
||||
{
|
||||
end = tv_get_number(&argvars[1]);
|
||||
@ -774,8 +789,7 @@ f_prop_list(typval_T *argvars, typval_T *rettv)
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_number_arg(argvars, 0) == FAIL
|
||||
|| (argvars[1].v_type != VAR_UNKNOWN &&
|
||||
check_for_dict_arg(argvars, 1) == FAIL)))
|
||||
|| check_for_opt_dict_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
lnum = tv_get_number(&argvars[0]);
|
||||
@ -832,6 +846,14 @@ f_prop_remove(typval_T *argvars, typval_T *rettv)
|
||||
int both;
|
||||
|
||||
rettv->vval.v_number = 0;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_dict_arg(argvars, 0) == FAIL
|
||||
|| check_for_opt_number_arg(argvars, 1) == FAIL
|
||||
|| (argvars[1].v_type != VAR_UNKNOWN
|
||||
&& check_for_opt_number_arg(argvars, 2) == FAIL)))
|
||||
return;
|
||||
|
||||
if (argvars[0].v_type != VAR_DICT || argvars[0].vval.v_dict == NULL)
|
||||
{
|
||||
emsg(_(e_invarg));
|
||||
|
10
src/time.c
10
src/time.c
@ -270,8 +270,7 @@ f_strftime(typval_T *argvars, typval_T *rettv)
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_string_arg(argvars, 0) == FAIL
|
||||
|| (argvars[1].v_type != VAR_UNKNOWN
|
||||
&& check_for_number_arg(argvars, 1) == FAIL)))
|
||||
|| check_for_opt_number_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
rettv->v_type = VAR_STRING;
|
||||
@ -777,12 +776,17 @@ f_timer_info(typval_T *argvars, typval_T *rettv)
|
||||
f_timer_pause(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
{
|
||||
timer_T *timer = NULL;
|
||||
int paused = (int)tv_get_bool(&argvars[1]);
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_number_arg(argvars, 0) == FAIL
|
||||
|| check_for_bool_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
if (argvars[0].v_type != VAR_NUMBER)
|
||||
emsg(_(e_number_exp));
|
||||
else
|
||||
{
|
||||
int paused = (int)tv_get_bool(&argvars[1]);
|
||||
timer = find_timer((int)tv_get_number(&argvars[0]));
|
||||
if (timer != NULL)
|
||||
timer->tr_paused = paused;
|
||||
|
203
src/typval.c
203
src/typval.c
@ -384,6 +384,16 @@ check_for_nonempty_string_arg(typval_T *args, int idx)
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for an optional string argument at 'idx'
|
||||
*/
|
||||
int
|
||||
check_for_opt_string_arg(typval_T *args, int idx)
|
||||
{
|
||||
return (args[idx].v_type == VAR_UNKNOWN
|
||||
|| check_for_string_arg(args, idx) != FAIL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Give an error and return FAIL unless "args[idx]" is a number.
|
||||
*/
|
||||
@ -401,6 +411,16 @@ check_for_number_arg(typval_T *args, int idx)
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for an optional number argument at 'idx'
|
||||
*/
|
||||
int
|
||||
check_for_opt_number_arg(typval_T *args, int idx)
|
||||
{
|
||||
return (args[idx].v_type == VAR_UNKNOWN
|
||||
|| check_for_number_arg(args, idx) != FAIL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Give an error and return FAIL unless "args[idx]" is a bool.
|
||||
*/
|
||||
@ -421,6 +441,16 @@ check_for_bool_arg(typval_T *args, int idx)
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for an optional bool argument at 'idx'
|
||||
*/
|
||||
int
|
||||
check_for_opt_bool_arg(typval_T *args, int idx)
|
||||
{
|
||||
return (args[idx].v_type == VAR_UNKNOWN
|
||||
|| check_for_bool_arg(args, idx) != FAIL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Give an error and return FAIL unless "args[idx]" is a list.
|
||||
*/
|
||||
@ -438,6 +468,16 @@ check_for_list_arg(typval_T *args, int idx)
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for an optional list argument at 'idx'
|
||||
*/
|
||||
int
|
||||
check_for_opt_list_arg(typval_T *args, int idx)
|
||||
{
|
||||
return (args[idx].v_type == VAR_UNKNOWN
|
||||
|| check_for_list_arg(args, idx) != FAIL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Give an error and return FAIL unless "args[idx]" is a dict.
|
||||
*/
|
||||
@ -455,6 +495,169 @@ check_for_dict_arg(typval_T *args, int idx)
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for an optional dict argument at 'idx'
|
||||
*/
|
||||
int
|
||||
check_for_opt_dict_arg(typval_T *args, int idx)
|
||||
{
|
||||
return (args[idx].v_type == VAR_UNKNOWN
|
||||
|| check_for_dict_arg(args, idx) != FAIL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Give an error and return FAIL unless "args[idx]" is a blob.
|
||||
*/
|
||||
int
|
||||
check_for_blob_arg(typval_T *args, int idx)
|
||||
{
|
||||
if (args[idx].v_type != VAR_BLOB)
|
||||
{
|
||||
if (idx >= 0)
|
||||
semsg(_(e_blob_required_for_argument_nr), idx + 1);
|
||||
else
|
||||
emsg(_(e_blobreq));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Give an error and return FAIL unless "args[idx]" is a channel or a job.
|
||||
*/
|
||||
int
|
||||
check_for_chan_or_job_arg(typval_T *args, int idx)
|
||||
{
|
||||
if (args[idx].v_type != VAR_CHANNEL && args[idx].v_type != VAR_JOB)
|
||||
{
|
||||
if (idx >= 0)
|
||||
semsg(_(e_chan_or_job_required_for_argument_nr), idx + 1);
|
||||
else
|
||||
emsg(_(e_chan_or_job_req));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Give an error and return FAIL unless "args[idx]" is a job.
|
||||
*/
|
||||
int
|
||||
check_for_job_arg(typval_T *args, int idx)
|
||||
{
|
||||
if (args[idx].v_type != VAR_JOB)
|
||||
{
|
||||
if (idx >= 0)
|
||||
semsg(_(e_job_required_for_argument_nr), idx + 1);
|
||||
else
|
||||
emsg(_(e_jobreq));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Give an error and return FAIL unless "args[idx]" is a string or
|
||||
* a number.
|
||||
*/
|
||||
int
|
||||
check_for_string_or_number_arg(typval_T *args, int idx)
|
||||
{
|
||||
if (args[idx].v_type != VAR_STRING && args[idx].v_type != VAR_NUMBER)
|
||||
{
|
||||
if (idx >= 0)
|
||||
semsg(_(e_string_required_for_argument_nr), idx + 1);
|
||||
else
|
||||
emsg(_(e_stringreq));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Give an error and return FAIL unless "args[idx]" is a string or
|
||||
* a number (buffer)
|
||||
*/
|
||||
int
|
||||
check_for_buffer_arg(typval_T *args, int idx)
|
||||
{
|
||||
if (args[idx].v_type != VAR_STRING && args[idx].v_type != VAR_NUMBER)
|
||||
{
|
||||
if (idx >= 0)
|
||||
semsg(_(e_string_required_for_argument_nr), idx + 1);
|
||||
else
|
||||
emsg(_(e_stringreq));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Give an error and return FAIL unless "args[idx]" is a string or
|
||||
* a number (line)
|
||||
*/
|
||||
int
|
||||
check_for_lnum_arg(typval_T *args, int idx)
|
||||
{
|
||||
if (args[idx].v_type != VAR_STRING && args[idx].v_type != VAR_NUMBER)
|
||||
{
|
||||
if (idx >= 0)
|
||||
semsg(_(e_string_required_for_argument_nr), idx + 1);
|
||||
else
|
||||
emsg(_(e_stringreq));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Give an error and return FAIL unless "args[idx]" is a string or
|
||||
* a number (line)
|
||||
*/
|
||||
int
|
||||
check_for_opt_lnum_arg(typval_T *args, int idx)
|
||||
{
|
||||
if (args[idx].v_type != VAR_UNKNOWN
|
||||
&& args[idx].v_type != VAR_STRING
|
||||
&& args[idx].v_type != VAR_NUMBER)
|
||||
{
|
||||
if (idx >= 0)
|
||||
semsg(_(e_string_required_for_argument_nr), idx + 1);
|
||||
else
|
||||
emsg(_(e_stringreq));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for an optional string or number argument at 'idx'
|
||||
*/
|
||||
int
|
||||
check_for_opt_string_or_number_arg(typval_T *args, int idx)
|
||||
{
|
||||
return (args[idx].v_type == VAR_UNKNOWN
|
||||
|| check_for_string_or_number_arg(args, idx) != FAIL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Give an error and return FAIL unless "args[idx]" is a string or
|
||||
* a blob.
|
||||
*/
|
||||
int
|
||||
check_for_string_or_blob_arg(typval_T *args, int idx)
|
||||
{
|
||||
if (args[idx].v_type != VAR_STRING && args[idx].v_type != VAR_BLOB)
|
||||
{
|
||||
if (idx >= 0)
|
||||
semsg(_(e_string_required_for_argument_nr), idx + 1);
|
||||
else
|
||||
emsg(_(e_stringreq));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the string value of a variable.
|
||||
* If it is a Number variable, the number is converted into a string.
|
||||
|
@ -755,6 +755,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
3188,
|
||||
/**/
|
||||
3187,
|
||||
/**/
|
||||
|
Loading…
x
Reference in New Issue
Block a user