mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.4408: Vim9: some code not covered by tests
Problem: Vim9: some code not covered by tests. Solution: Add a few more tests. Correct error message. Allow unlet on dict with a number key.
This commit is contained in:
@@ -3010,8 +3010,7 @@ EXTERN char e_variable_arguments_type_must_be_list_str[]
|
|||||||
INIT(= N_("E1180: Variable arguments type must be a list: %s"));
|
INIT(= N_("E1180: Variable arguments type must be a list: %s"));
|
||||||
EXTERN char e_cannot_use_underscore_here[]
|
EXTERN char e_cannot_use_underscore_here[]
|
||||||
INIT(= N_("E1181: Cannot use an underscore here"));
|
INIT(= N_("E1181: Cannot use an underscore here"));
|
||||||
EXTERN char e_blob_required[]
|
// E1182 unused
|
||||||
INIT(= N_("E1182: Blob required"));
|
|
||||||
EXTERN char e_cannot_use_range_with_assignment_operator_str[]
|
EXTERN char e_cannot_use_range_with_assignment_operator_str[]
|
||||||
INIT(= N_("E1183: Cannot use a range with an assignment operator: %s"));
|
INIT(= N_("E1183: Cannot use a range with an assignment operator: %s"));
|
||||||
#endif
|
#endif
|
||||||
|
@@ -610,6 +610,12 @@ def Test_assign_index()
|
|||||||
bl[1] = 8
|
bl[1] = 8
|
||||||
END
|
END
|
||||||
v9.CheckDefExecAndScriptFailure(lines, ['E1184:', 'E979:'], 2)
|
v9.CheckDefExecAndScriptFailure(lines, ['E1184:', 'E979:'], 2)
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
g:bl = 'not a blob'
|
||||||
|
g:bl[1 : 2] = 8
|
||||||
|
END
|
||||||
|
v9.CheckDefExecAndScriptFailure(lines, ['E897:', 'E689:'], 2)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_init_in_for_loop()
|
def Test_init_in_for_loop()
|
||||||
@@ -1231,6 +1237,7 @@ def Test_script_var_default()
|
|||||||
assert_equal(0z, bl)
|
assert_equal(0z, bl)
|
||||||
assert_equal({}, d)
|
assert_equal({}, d)
|
||||||
enddef
|
enddef
|
||||||
|
Echo()
|
||||||
END
|
END
|
||||||
v9.CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
@@ -2070,9 +2077,10 @@ def Test_unlet()
|
|||||||
], 'E1081:', 2)
|
], 'E1081:', 2)
|
||||||
|
|
||||||
# dict unlet
|
# dict unlet
|
||||||
var dd = {a: 1, b: 2, c: 3}
|
var dd = {a: 1, b: 2, c: 3, 4: 4}
|
||||||
unlet dd['a']
|
unlet dd['a']
|
||||||
unlet dd.c
|
unlet dd.c
|
||||||
|
unlet dd[4]
|
||||||
assert_equal({b: 2}, dd)
|
assert_equal({b: 2}, dd)
|
||||||
|
|
||||||
# list unlet
|
# list unlet
|
||||||
@@ -2181,6 +2189,11 @@ def Test_unlet()
|
|||||||
'unlet dd[g:alist]',
|
'unlet dd[g:alist]',
|
||||||
], 'E1105:', 2)
|
], 'E1105:', 2)
|
||||||
|
|
||||||
|
v9.CheckDefExecFailure([
|
||||||
|
'g:dd = {"a": 1, 2: 2}'
|
||||||
|
'unlet g:dd[0z11]',
|
||||||
|
], 'E1029:', 2)
|
||||||
|
|
||||||
# can compile unlet before variable exists
|
# can compile unlet before variable exists
|
||||||
g:someDict = {key: 'val'}
|
g:someDict = {key: 'val'}
|
||||||
var k = 'key'
|
var k = 'key'
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
4408,
|
||||||
/**/
|
/**/
|
||||||
4407,
|
4407,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -1876,7 +1876,7 @@ execute_storeindex(isn_T *iptr, ectx_T *ectx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Store a value in a blob range.
|
* Store a value in a list or blob range.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
execute_storerange(isn_T *iptr, ectx_T *ectx)
|
execute_storerange(isn_T *iptr, ectx_T *ectx)
|
||||||
@@ -1893,13 +1893,13 @@ execute_storerange(isn_T *iptr, ectx_T *ectx)
|
|||||||
// -2 second index or "none"
|
// -2 second index or "none"
|
||||||
// -1 destination list or blob
|
// -1 destination list or blob
|
||||||
tv = STACK_TV_BOT(-4);
|
tv = STACK_TV_BOT(-4);
|
||||||
|
SOURCING_LNUM = iptr->isn_lnum;
|
||||||
if (tv_dest->v_type == VAR_LIST)
|
if (tv_dest->v_type == VAR_LIST)
|
||||||
{
|
{
|
||||||
long n1;
|
long n1;
|
||||||
long n2;
|
long n2;
|
||||||
int error = FALSE;
|
int error = FALSE;
|
||||||
|
|
||||||
SOURCING_LNUM = iptr->isn_lnum;
|
|
||||||
n1 = (long)tv_get_number_chk(tv_idx1, &error);
|
n1 = (long)tv_get_number_chk(tv_idx1, &error);
|
||||||
if (error)
|
if (error)
|
||||||
status = FAIL;
|
status = FAIL;
|
||||||
@@ -1973,7 +1973,7 @@ execute_storerange(isn_T *iptr, ectx_T *ectx)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
status = FAIL;
|
status = FAIL;
|
||||||
emsg(_(e_blob_required));
|
emsg(_(e_list_or_blob_required));
|
||||||
}
|
}
|
||||||
|
|
||||||
clear_tv(tv_idx1);
|
clear_tv(tv_idx1);
|
||||||
@@ -2001,7 +2001,7 @@ execute_unletindex(isn_T *iptr, ectx_T *ectx)
|
|||||||
if (tv_dest->v_type == VAR_DICT)
|
if (tv_dest->v_type == VAR_DICT)
|
||||||
{
|
{
|
||||||
// unlet a dict item, index must be a string
|
// unlet a dict item, index must be a string
|
||||||
if (tv_idx->v_type != VAR_STRING)
|
if (tv_idx->v_type != VAR_STRING && tv_idx->v_type != VAR_NUMBER)
|
||||||
{
|
{
|
||||||
SOURCING_LNUM = iptr->isn_lnum;
|
SOURCING_LNUM = iptr->isn_lnum;
|
||||||
semsg(_(e_expected_str_but_got_str),
|
semsg(_(e_expected_str_but_got_str),
|
||||||
@@ -2012,7 +2012,7 @@ execute_unletindex(isn_T *iptr, ectx_T *ectx)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
dict_T *d = tv_dest->vval.v_dict;
|
dict_T *d = tv_dest->vval.v_dict;
|
||||||
char_u *key = tv_idx->vval.v_string;
|
char_u *key;
|
||||||
dictitem_T *di = NULL;
|
dictitem_T *di = NULL;
|
||||||
|
|
||||||
if (d != NULL && value_check_lock(
|
if (d != NULL && value_check_lock(
|
||||||
@@ -2021,8 +2021,16 @@ execute_unletindex(isn_T *iptr, ectx_T *ectx)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
SOURCING_LNUM = iptr->isn_lnum;
|
SOURCING_LNUM = iptr->isn_lnum;
|
||||||
if (key == NULL)
|
if (tv_idx->v_type == VAR_STRING)
|
||||||
key = (char_u *)"";
|
{
|
||||||
|
key = tv_idx->vval.v_string;
|
||||||
|
if (key == NULL)
|
||||||
|
key = (char_u *)"";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
key = tv_get_string(tv_idx);
|
||||||
|
}
|
||||||
if (d != NULL)
|
if (d != NULL)
|
||||||
di = dict_find(d, key, (int)STRLEN(key));
|
di = dict_find(d, key, (int)STRLEN(key));
|
||||||
if (di == NULL)
|
if (di == NULL)
|
||||||
@@ -3173,7 +3181,7 @@ exec_instructions(ectx_T *ectx)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// store value in blob range
|
// store value in list or blob range
|
||||||
case ISN_STORERANGE:
|
case ISN_STORERANGE:
|
||||||
if (execute_storerange(iptr, ectx) == FAIL)
|
if (execute_storerange(iptr, ectx) == FAIL)
|
||||||
goto on_error;
|
goto on_error;
|
||||||
|
Reference in New Issue
Block a user