mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
patch 8.2.4834: Vim9: some lines not covered by tests
Problem: Vim9: some lines not covered by tests. Solution: Add a few more tests. Remove dead code.
This commit is contained in:
@@ -1848,8 +1848,12 @@ def Test_expr6()
|
|||||||
v9.CheckDefFailure(["var d = 6 * "], 'E1097:', 3)
|
v9.CheckDefFailure(["var d = 6 * "], 'E1097:', 3)
|
||||||
v9.CheckScriptFailure(['vim9script', "var d = 6 * "], 'E15:', 2)
|
v9.CheckScriptFailure(['vim9script', "var d = 6 * "], 'E15:', 2)
|
||||||
|
|
||||||
v9.CheckDefExecAndScriptFailure(['echo 1 / 0'], 'E1154', 1)
|
v9.CheckDefAndScriptFailure(['echo 1 / 0'], 'E1154', 1)
|
||||||
v9.CheckDefExecAndScriptFailure(['echo 1 % 0'], 'E1154', 1)
|
v9.CheckDefAndScriptFailure(['echo 1 % 0'], 'E1154', 1)
|
||||||
|
|
||||||
|
g:zero = 0
|
||||||
|
v9.CheckDefExecFailure(['echo 123 / g:zero'], 'E1154: Divide by zero')
|
||||||
|
v9.CheckDefExecFailure(['echo 123 % g:zero'], 'E1154: Divide by zero')
|
||||||
|
|
||||||
if has('float')
|
if has('float')
|
||||||
v9.CheckDefExecAndScriptFailure([
|
v9.CheckDefExecAndScriptFailure([
|
||||||
@@ -3396,6 +3400,15 @@ def Test_expr8_legacy_script()
|
|||||||
|
|
||||||
assert_equal('ok', g:LegacyReturn())
|
assert_equal('ok', g:LegacyReturn())
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
def GetNumber(): number
|
||||||
|
legacy return notexists
|
||||||
|
enddef
|
||||||
|
echo GetNumber()
|
||||||
|
END
|
||||||
|
v9.CheckScriptFailure(lines, 'E121: Undefined variable: notexists')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
def GetNumber(): number
|
def GetNumber(): number
|
||||||
|
@@ -746,6 +746,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 */
|
||||||
|
/**/
|
||||||
|
4834,
|
||||||
/**/
|
/**/
|
||||||
4833,
|
4833,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -173,7 +173,6 @@ typedef enum {
|
|||||||
ISN_2STRING_ANY, // like ISN_2STRING but check type
|
ISN_2STRING_ANY, // like ISN_2STRING but check type
|
||||||
ISN_NEGATENR, // apply "-" to number
|
ISN_NEGATENR, // apply "-" to number
|
||||||
|
|
||||||
ISN_CHECKNR, // check value can be used as a number
|
|
||||||
ISN_CHECKTYPE, // check value type is isn_arg.type.ct_type
|
ISN_CHECKTYPE, // check value type is isn_arg.type.ct_type
|
||||||
ISN_CHECKLEN, // check list length is isn_arg.checklen.cl_min_len
|
ISN_CHECKLEN, // check list length is isn_arg.checklen.cl_min_len
|
||||||
ISN_SETTYPE, // set dict type to isn_arg.type.ct_type
|
ISN_SETTYPE, // set dict type to isn_arg.type.ct_type
|
||||||
|
@@ -3172,6 +3172,7 @@ exec_instructions(ectx_T *ectx)
|
|||||||
int idx = get_script_item_idx(sid, name, 0,
|
int idx = get_script_item_idx(sid, name, 0,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
|
// can this ever fail?
|
||||||
if (idx >= 0)
|
if (idx >= 0)
|
||||||
{
|
{
|
||||||
svar_T *sv = ((svar_T *)SCRIPT_ITEM(sid)
|
svar_T *sv = ((svar_T *)SCRIPT_ITEM(sid)
|
||||||
@@ -3862,15 +3863,14 @@ exec_instructions(ectx_T *ectx)
|
|||||||
case ISN_CATCH:
|
case ISN_CATCH:
|
||||||
{
|
{
|
||||||
garray_T *trystack = &ectx->ec_trystack;
|
garray_T *trystack = &ectx->ec_trystack;
|
||||||
|
trycmd_T *trycmd;
|
||||||
|
|
||||||
may_restore_cmdmod(&ectx->ec_funclocal);
|
may_restore_cmdmod(&ectx->ec_funclocal);
|
||||||
if (trystack->ga_len > 0)
|
trycmd = ((trycmd_T *)trystack->ga_data)
|
||||||
{
|
|
||||||
trycmd_T *trycmd = ((trycmd_T *)trystack->ga_data)
|
|
||||||
+ trystack->ga_len - 1;
|
+ trystack->ga_len - 1;
|
||||||
trycmd->tcd_caught = TRUE;
|
trycmd->tcd_caught = TRUE;
|
||||||
trycmd->tcd_did_throw = FALSE;
|
trycmd->tcd_did_throw = FALSE;
|
||||||
}
|
|
||||||
did_emsg = got_int = did_throw = FALSE;
|
did_emsg = got_int = did_throw = FALSE;
|
||||||
force_abort = need_rethrow = FALSE;
|
force_abort = need_rethrow = FALSE;
|
||||||
catch_exception(current_exception);
|
catch_exception(current_exception);
|
||||||
@@ -3924,15 +3924,11 @@ exec_instructions(ectx_T *ectx)
|
|||||||
case ISN_ENDTRY:
|
case ISN_ENDTRY:
|
||||||
{
|
{
|
||||||
garray_T *trystack = &ectx->ec_trystack;
|
garray_T *trystack = &ectx->ec_trystack;
|
||||||
|
|
||||||
if (trystack->ga_len > 0)
|
|
||||||
{
|
|
||||||
trycmd_T *trycmd;
|
trycmd_T *trycmd;
|
||||||
|
|
||||||
--trystack->ga_len;
|
--trystack->ga_len;
|
||||||
--trylevel;
|
--trylevel;
|
||||||
trycmd = ((trycmd_T *)trystack->ga_data)
|
trycmd = ((trycmd_T *)trystack->ga_data) + trystack->ga_len;
|
||||||
+ trystack->ga_len;
|
|
||||||
if (trycmd->tcd_did_throw)
|
if (trycmd->tcd_did_throw)
|
||||||
did_throw = TRUE;
|
did_throw = TRUE;
|
||||||
if (trycmd->tcd_caught && current_exception != NULL)
|
if (trycmd->tcd_caught && current_exception != NULL)
|
||||||
@@ -3956,7 +3952,6 @@ exec_instructions(ectx_T *ectx)
|
|||||||
// start of the loop
|
// start of the loop
|
||||||
ectx->ec_iidx = trycmd->tcd_cont - 1;
|
ectx->ec_iidx = trycmd->tcd_cont - 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ISN_THROW:
|
case ISN_THROW:
|
||||||
@@ -4021,12 +4016,10 @@ exec_instructions(ectx_T *ectx)
|
|||||||
varnumber_T arg2 = tv2->vval.v_number;
|
varnumber_T arg2 = tv2->vval.v_number;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
switch (iptr->isn_arg.op.op_type)
|
if (iptr->isn_arg.op.op_type == EXPR_EQUAL)
|
||||||
{
|
res = arg1 == arg2;
|
||||||
case EXPR_EQUAL: res = arg1 == arg2; break;
|
else
|
||||||
case EXPR_NEQUAL: res = arg1 != arg2; break;
|
res = arg1 != arg2;
|
||||||
default: res = 0; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
--ectx->ec_stack.ga_len;
|
--ectx->ec_stack.ga_len;
|
||||||
tv1->v_type = VAR_BOOL;
|
tv1->v_type = VAR_BOOL;
|
||||||
@@ -4658,20 +4651,6 @@ exec_instructions(ectx_T *ectx)
|
|||||||
tv->vval.v_number = -tv->vval.v_number;
|
tv->vval.v_number = -tv->vval.v_number;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ISN_CHECKNR:
|
|
||||||
{
|
|
||||||
int error = FALSE;
|
|
||||||
|
|
||||||
tv = STACK_TV_BOT(-1);
|
|
||||||
SOURCING_LNUM = iptr->isn_lnum;
|
|
||||||
if (check_not_string(tv) == FAIL)
|
|
||||||
goto on_error;
|
|
||||||
(void)tv_get_number_chk(tv, &error);
|
|
||||||
if (error)
|
|
||||||
goto on_error;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ISN_CHECKTYPE:
|
case ISN_CHECKTYPE:
|
||||||
{
|
{
|
||||||
checktype_T *ct = &iptr->isn_arg.type;
|
checktype_T *ct = &iptr->isn_arg.type;
|
||||||
@@ -4778,9 +4757,6 @@ exec_instructions(ectx_T *ectx)
|
|||||||
tv = STACK_TV_BOT(-1);
|
tv = STACK_TV_BOT(-1);
|
||||||
tv->v_type = VAR_NUMBER;
|
tv->v_type = VAR_NUMBER;
|
||||||
tv->v_lock = 0;
|
tv->v_lock = 0;
|
||||||
if (ea.addr_count == 0)
|
|
||||||
tv->vval.v_number = curwin->w_cursor.lnum;
|
|
||||||
else
|
|
||||||
tv->vval.v_number = ea.line2;
|
tv->vval.v_number = ea.line2;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -6144,7 +6120,6 @@ list_instructions(char *pfx, isn_T *instr, int instr_count, ufunc_T *ufunc)
|
|||||||
|
|
||||||
case ISN_NEGATENR: smsg("%s%4d NEGATENR", pfx, current); break;
|
case ISN_NEGATENR: smsg("%s%4d NEGATENR", pfx, current); break;
|
||||||
|
|
||||||
case ISN_CHECKNR: smsg("%s%4d CHECKNR", pfx, current); break;
|
|
||||||
case ISN_CHECKTYPE:
|
case ISN_CHECKTYPE:
|
||||||
{
|
{
|
||||||
checktype_T *ct = &iptr->isn_arg.type;
|
checktype_T *ct = &iptr->isn_arg.type;
|
||||||
|
@@ -2231,7 +2231,6 @@ delete_instr(isn_T *isn)
|
|||||||
case ISN_CATCH:
|
case ISN_CATCH:
|
||||||
case ISN_CEXPR_AUCMD:
|
case ISN_CEXPR_AUCMD:
|
||||||
case ISN_CHECKLEN:
|
case ISN_CHECKLEN:
|
||||||
case ISN_CHECKNR:
|
|
||||||
case ISN_CLEARDICT:
|
case ISN_CLEARDICT:
|
||||||
case ISN_CMDMOD_REV:
|
case ISN_CMDMOD_REV:
|
||||||
case ISN_COMPAREANY:
|
case ISN_COMPAREANY:
|
||||||
|
Reference in New Issue
Block a user