0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.2710: Vim9: not all tests cover script and :def function

Problem:    Vim9: not all tests cover script and :def function.
Solution:   Run tests in both if possible. Fix differences.
This commit is contained in:
Bram Moolenaar
2021-04-04 20:49:50 +02:00
parent 26af8e54ff
commit 90193e6140
6 changed files with 761 additions and 742 deletions

View File

@@ -2330,7 +2330,7 @@ eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
{ {
if (evaluate && vim9script && !VIM_ISWHITE(p[-1])) if (evaluate && vim9script && !VIM_ISWHITE(p[-1]))
{ {
error_white_both(p, 1); error_white_both(p, op_falsy ? 2 : 1);
clear_tv(rettv); clear_tv(rettv);
return FAIL; return FAIL;
} }
@@ -2361,7 +2361,7 @@ eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
++*arg; ++*arg;
if (evaluate && vim9script && !IS_WHITE_OR_NUL((*arg)[1])) if (evaluate && vim9script && !IS_WHITE_OR_NUL((*arg)[1]))
{ {
error_white_both(p, 1); error_white_both(p, op_falsy ? 2 : 1);
clear_tv(rettv); clear_tv(rettv);
return FAIL; return FAIL;
} }
@@ -2774,7 +2774,7 @@ eval4(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
*/ */
if (evaluate && vim9script && !IS_WHITE_OR_NUL(p[len])) if (evaluate && vim9script && !IS_WHITE_OR_NUL(p[len]))
{ {
error_white_both(p, 1); error_white_both(p, len);
clear_tv(rettv); clear_tv(rettv);
return FAIL; return FAIL;
} }
@@ -3438,9 +3438,16 @@ eval7(
case '@': ++*arg; case '@': ++*arg;
if (evaluate) if (evaluate)
{ {
rettv->v_type = VAR_STRING; if (in_vim9script() && IS_WHITE_OR_NUL(**arg))
rettv->vval.v_string = get_reg_contents(**arg, semsg(_(e_syntax_error_at_str), *arg);
GREG_EXPR_SRC); else if (in_vim9script() && !valid_yank_reg(**arg, FALSE))
emsg_invreg(**arg);
else
{
rettv->v_type = VAR_STRING;
rettv->vval.v_string = get_reg_contents(**arg,
GREG_EXPR_SRC);
}
} }
if (**arg != NUL) if (**arg != NUL)
++*arg; ++*arg;

File diff suppressed because it is too large Load Diff

View File

@@ -107,9 +107,29 @@ def CheckDefAndScriptFailure(lines: list<string>, error: string, lnum = -3)
CheckScriptFailure(['vim9script'] + lines, error, lnum + 1) CheckScriptFailure(['vim9script'] + lines, error, lnum + 1)
enddef enddef
" As CheckDefAndScriptFailure() but with two different exepcted errors.
def CheckDefAndScriptFailure2(
lines: list<string>,
errorDef: string,
errorScript: string,
lnum = -3)
CheckDefFailure(lines, errorDef, lnum)
CheckScriptFailure(['vim9script'] + lines, errorScript, lnum + 1)
enddef
" Check that a command fails with the same error when executed in a :def " Check that a command fails with the same error when executed in a :def
" function and when used in Vim9 script. " function and when used in Vim9 script.
def CheckDefExecAndScriptFailure(lines: list<string>, error: string, lnum = -3) def CheckDefExecAndScriptFailure(lines: list<string>, error: string, lnum = -3)
CheckDefExecFailure(lines, error, lnum) CheckDefExecFailure(lines, error, lnum)
CheckScriptFailure(['vim9script'] + lines, error, lnum + 1) CheckScriptFailure(['vim9script'] + lines, error, lnum + 1)
enddef enddef
" As CheckDefExecAndScriptFailure() but with two different expected errors.
def CheckDefExecAndScriptFailure2(
lines: list<string>,
errorDef: string,
errorScript: string,
lnum = -3)
CheckDefExecFailure(lines, errorDef, lnum)
CheckScriptFailure(['vim9script'] + lines, errorScript, lnum + 1)
enddef

View File

@@ -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 */
/**/
2710,
/**/ /**/
2709, 2709,
/**/ /**/

View File

@@ -4106,7 +4106,7 @@ compile_subscript(
ppconst->pp_is_const = FALSE; ppconst->pp_is_const = FALSE;
*arg = p + 1; *arg = p + 1;
if (may_get_next_line(*arg, arg, cctx) == FAIL) if (IS_WHITE_OR_NUL(**arg))
{ {
emsg(_(e_missing_name_after_dot)); emsg(_(e_missing_name_after_dot));
return FAIL; return FAIL;
@@ -4785,7 +4785,7 @@ compile_and_or(
if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[2])) if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[2]))
{ {
semsg(_(e_white_space_required_before_and_after_str_at_str), semsg(_(e_white_space_required_before_and_after_str_at_str),
op, *arg); op, p);
return FAIL; return FAIL;
} }

View File

@@ -3962,9 +3962,16 @@ on_fatal_error:
done: done:
// function finished, get result from the stack. // function finished, get result from the stack.
tv = STACK_TV_BOT(-1); if (ufunc->uf_ret_type == &t_void)
*rettv = *tv; {
tv->v_type = VAR_UNKNOWN; rettv->v_type = VAR_VOID;
}
else
{
tv = STACK_TV_BOT(-1);
*rettv = *tv;
tv->v_type = VAR_UNKNOWN;
}
ret = OK; ret = OK;
failed: failed: