mirror of
https://github.com/vim/vim.git
synced 2025-09-04 21:33:48 -04:00
patch 8.2.4410: Vim9: some code not covered by tests
Problem: Vim9: some code not covered by tests. Solution: Add a few more tests. Remove dead code.
This commit is contained in:
parent
6296d1e60e
commit
0c7f2610de
@ -2104,6 +2104,13 @@ def Test_unlet()
|
|||||||
unlet ll[-2 : -1]
|
unlet ll[-2 : -1]
|
||||||
assert_equal([1, 2], ll)
|
assert_equal([1, 2], ll)
|
||||||
|
|
||||||
|
g:nrdict = {1: 1, 2: 2}
|
||||||
|
g:idx = 1
|
||||||
|
unlet g:nrdict[g:idx]
|
||||||
|
assert_equal({2: 2}, g:nrdict)
|
||||||
|
unlet g:nrdict
|
||||||
|
unlet g:idx
|
||||||
|
|
||||||
v9.CheckDefFailure([
|
v9.CheckDefFailure([
|
||||||
'var ll = [1, 2]',
|
'var ll = [1, 2]',
|
||||||
'll[1 : 2] = 7',
|
'll[1 : 2] = 7',
|
||||||
|
@ -1551,6 +1551,28 @@ def Test_lockvar()
|
|||||||
END
|
END
|
||||||
v9.CheckScriptFailure(lines, 'E1119', 4)
|
v9.CheckScriptFailure(lines, 'E1119', 4)
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
var theList = [1, 2, 3]
|
||||||
|
def AddToList()
|
||||||
|
lockvar theList
|
||||||
|
theList += [4]
|
||||||
|
enddef
|
||||||
|
AddToList()
|
||||||
|
END
|
||||||
|
v9.CheckScriptFailure(lines, 'E741', 2)
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
var theList = [1, 2, 3]
|
||||||
|
def AddToList()
|
||||||
|
lockvar theList
|
||||||
|
add(theList, 4)
|
||||||
|
enddef
|
||||||
|
AddToList()
|
||||||
|
END
|
||||||
|
v9.CheckScriptFailure(lines, 'E741', 2)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
var theList = [1, 2, 3]
|
var theList = [1, 2, 3]
|
||||||
lockvar theList
|
lockvar theList
|
||||||
|
@ -1556,6 +1556,14 @@ def Test_expr6()
|
|||||||
v9.CheckDefExecAndScriptFailure(['echo 1 / 0'], 'E1154', 1)
|
v9.CheckDefExecAndScriptFailure(['echo 1 / 0'], 'E1154', 1)
|
||||||
v9.CheckDefExecAndScriptFailure(['echo 1 % 0'], 'E1154', 1)
|
v9.CheckDefExecAndScriptFailure(['echo 1 % 0'], 'E1154', 1)
|
||||||
|
|
||||||
|
if has('float')
|
||||||
|
v9.CheckDefExecAndScriptFailure([
|
||||||
|
'g:one = 1.0'
|
||||||
|
'g:two = 2.0'
|
||||||
|
'echo g:one % g:two'
|
||||||
|
], 'E804', 3)
|
||||||
|
endif
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
var n = 0
|
var n = 0
|
||||||
eval 1 / n
|
eval 1 / n
|
||||||
|
@ -52,6 +52,15 @@ def Test_range_only()
|
|||||||
|
|
||||||
bwipe!
|
bwipe!
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
set cpo+=-
|
||||||
|
:1,999
|
||||||
|
END
|
||||||
|
v9.CheckDefExecAndScriptFailure(lines, 'E16:', 2)
|
||||||
|
set cpo&vim
|
||||||
|
|
||||||
|
v9.CheckDefExecAndScriptFailure([":'x"], 'E20:', 1)
|
||||||
|
|
||||||
# won't generate anything
|
# won't generate anything
|
||||||
if false
|
if false
|
||||||
:123
|
:123
|
||||||
@ -1726,6 +1735,9 @@ def Test_execute_cmd()
|
|||||||
v9.CheckDefFailure(['execute xxx'], 'E1001:', 1)
|
v9.CheckDefFailure(['execute xxx'], 'E1001:', 1)
|
||||||
v9.CheckDefExecFailure(['execute "tabnext " .. 8'], 'E475:', 1)
|
v9.CheckDefExecFailure(['execute "tabnext " .. 8'], 'E475:', 1)
|
||||||
v9.CheckDefFailure(['execute "cmd"# comment'], 'E488:', 1)
|
v9.CheckDefFailure(['execute "cmd"# comment'], 'E488:', 1)
|
||||||
|
if has('channel')
|
||||||
|
v9.CheckDefExecFailure(['execute test_null_channel()'], 'E908:', 1)
|
||||||
|
endif
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_execute_cmd_vimscript()
|
def Test_execute_cmd_vimscript()
|
||||||
|
@ -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 */
|
||||||
|
/**/
|
||||||
|
4410,
|
||||||
/**/
|
/**/
|
||||||
4409,
|
4409,
|
||||||
/**/
|
/**/
|
||||||
|
@ -2331,19 +2331,6 @@ load_namespace_var(ectx_T *ectx, isntype_T isn_type, isn_T *iptr)
|
|||||||
}
|
}
|
||||||
di = find_var_in_ht(ht, 0, iptr->isn_arg.string, TRUE);
|
di = find_var_in_ht(ht, 0, iptr->isn_arg.string, TRUE);
|
||||||
|
|
||||||
if (di == NULL && ht == get_globvar_ht()
|
|
||||||
&& vim_strchr(iptr->isn_arg.string,
|
|
||||||
AUTOLOAD_CHAR) != NULL)
|
|
||||||
{
|
|
||||||
// Global variable has an autoload name, may still need
|
|
||||||
// to load the script.
|
|
||||||
if (script_autoload(iptr->isn_arg.string, FALSE))
|
|
||||||
di = find_var_in_ht(ht, 0,
|
|
||||||
iptr->isn_arg.string, TRUE);
|
|
||||||
if (did_emsg)
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (di == NULL)
|
if (di == NULL)
|
||||||
{
|
{
|
||||||
SOURCING_LNUM = iptr->isn_lnum;
|
SOURCING_LNUM = iptr->isn_lnum;
|
||||||
@ -2520,14 +2507,14 @@ exec_instructions(ectx_T *ectx)
|
|||||||
ea.cmdidx = CMD_SIZE;
|
ea.cmdidx = CMD_SIZE;
|
||||||
ea.addr_type = ADDR_LINES;
|
ea.addr_type = ADDR_LINES;
|
||||||
ea.cmd = iptr->isn_arg.string;
|
ea.cmd = iptr->isn_arg.string;
|
||||||
|
SOURCING_LNUM = iptr->isn_lnum;
|
||||||
parse_cmd_address(&ea, &error, FALSE);
|
parse_cmd_address(&ea, &error, FALSE);
|
||||||
if (ea.cmd == NULL)
|
if (ea.cmd == NULL)
|
||||||
goto on_error;
|
goto on_error;
|
||||||
if (error == NULL)
|
// error is always NULL when using ADDR_LINES
|
||||||
error = ex_range_without_command(&ea);
|
error = ex_range_without_command(&ea);
|
||||||
if (error != NULL)
|
if (error != NULL)
|
||||||
{
|
{
|
||||||
SOURCING_LNUM = iptr->isn_lnum;
|
|
||||||
emsg(error);
|
emsg(error);
|
||||||
goto on_error;
|
goto on_error;
|
||||||
}
|
}
|
||||||
@ -3566,12 +3553,6 @@ exec_instructions(ectx_T *ectx)
|
|||||||
{
|
{
|
||||||
ufunc = find_func(funcref->fr_func_name, FALSE);
|
ufunc = find_func(funcref->fr_func_name, FALSE);
|
||||||
}
|
}
|
||||||
if (ufunc == NULL)
|
|
||||||
{
|
|
||||||
SOURCING_LNUM = iptr->isn_lnum;
|
|
||||||
emsg(_(e_function_reference_invalid));
|
|
||||||
goto theend;
|
|
||||||
}
|
|
||||||
if (fill_partial_and_closure(pt, ufunc, ectx) == FAIL)
|
if (fill_partial_and_closure(pt, ufunc, ectx) == FAIL)
|
||||||
goto theend;
|
goto theend;
|
||||||
tv = STACK_TV_BOT(0);
|
tv = STACK_TV_BOT(0);
|
||||||
@ -4488,16 +4469,7 @@ exec_instructions(ectx_T *ectx)
|
|||||||
|
|
||||||
case ISN_NEGATENR:
|
case ISN_NEGATENR:
|
||||||
tv = STACK_TV_BOT(-1);
|
tv = STACK_TV_BOT(-1);
|
||||||
if (tv->v_type != VAR_NUMBER
|
// CHECKTYPE should have checked the variable type
|
||||||
#ifdef FEAT_FLOAT
|
|
||||||
&& tv->v_type != VAR_FLOAT
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{
|
|
||||||
SOURCING_LNUM = iptr->isn_lnum;
|
|
||||||
emsg(_(e_number_expected));
|
|
||||||
goto on_error;
|
|
||||||
}
|
|
||||||
#ifdef FEAT_FLOAT
|
#ifdef FEAT_FLOAT
|
||||||
if (tv->v_type == VAR_FLOAT)
|
if (tv->v_type == VAR_FLOAT)
|
||||||
tv->vval.v_float = -tv->vval.v_float;
|
tv->vval.v_float = -tv->vval.v_float;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user