1
0
forked from aniani/vim

patch 8.2.3335: Vim9: not enough tests run with Vim9

Problem:    Vim9: not enough tests run with Vim9.
Solution:   Run a few more tests in Vim9 script and :def function.  Fix that
            items(), keys() and values9) return zero for a NULL dict.
            Make join() return an empty string for a NULL list.  Make sort()
            return an empty list for a NULL list.
This commit is contained in:
Bram Moolenaar
2021-08-12 19:27:57 +02:00
parent bd77aa9274
commit ef98257593
5 changed files with 248 additions and 191 deletions

View File

@@ -1436,15 +1436,15 @@ f_join(typval_T *argvars, typval_T *rettv)
emsg(_(e_listreq));
return;
}
rettv->v_type = VAR_STRING;
if (argvars[0].vval.v_list == NULL)
return;
if (argvars[1].v_type == VAR_UNKNOWN)
sep = (char_u *)" ";
else
sep = tv_get_string_chk(&argvars[1]);
rettv->v_type = VAR_STRING;
if (sep != NULL)
{
ga_init2(&ga, (int)sizeof(char), 80);
@@ -1968,11 +1968,13 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort)
else
{
l = argvars[0].vval.v_list;
if (l == NULL || value_check_lock(l->lv_lock,
if (l != NULL && value_check_lock(l->lv_lock,
(char_u *)(sort ? N_("sort() argument") : N_("uniq() argument")),
TRUE))
goto theend;
rettv_list_set(rettv, l);
if (l == NULL)
goto theend;
CHECK_LIST_MATERIALIZE(l);
len = list_len(l);
@@ -3110,32 +3112,35 @@ f_reverse(typval_T *argvars, typval_T *rettv)
if (argvars[0].v_type != VAR_LIST)
semsg(_(e_listblobarg), "reverse()");
else if ((l = argvars[0].vval.v_list) != NULL
else
{
l = argvars[0].vval.v_list;
rettv_list_set(rettv, l);
if (l != NULL
&& !value_check_lock(l->lv_lock,
(char_u *)N_("reverse() argument"), TRUE))
{
if (l->lv_first == &range_list_item)
{
varnumber_T new_start = l->lv_u.nonmat.lv_start
if (l->lv_first == &range_list_item)
{
varnumber_T new_start = l->lv_u.nonmat.lv_start
+ (l->lv_len - 1) * l->lv_u.nonmat.lv_stride;
l->lv_u.nonmat.lv_end = new_start
l->lv_u.nonmat.lv_end = new_start
- (l->lv_u.nonmat.lv_end - l->lv_u.nonmat.lv_start);
l->lv_u.nonmat.lv_start = new_start;
l->lv_u.nonmat.lv_stride = -l->lv_u.nonmat.lv_stride;
rettv_list_set(rettv, l);
return;
l->lv_u.nonmat.lv_start = new_start;
l->lv_u.nonmat.lv_stride = -l->lv_u.nonmat.lv_stride;
return;
}
li = l->lv_u.mat.lv_last;
l->lv_first = l->lv_u.mat.lv_last = NULL;
l->lv_len = 0;
while (li != NULL)
{
ni = li->li_prev;
list_append(l, li);
li = ni;
}
l->lv_u.mat.lv_idx = l->lv_len - l->lv_u.mat.lv_idx - 1;
}
li = l->lv_u.mat.lv_last;
l->lv_first = l->lv_u.mat.lv_last = NULL;
l->lv_len = 0;
while (li != NULL)
{
ni = li->li_prev;
list_append(l, li);
li = ni;
}
rettv_list_set(rettv, l);
l->lv_u.mat.lv_idx = l->lv_len - l->lv_u.mat.lv_idx - 1;
}
}