mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.2645: using inline function is not properly tested
Problem: Using inline function is not properly tested. Solution: Add test cases, esp. for errors. Minor code improvements.
This commit is contained in:
@@ -381,3 +381,5 @@ EXTERN char e_missing_end_block[]
|
|||||||
INIT(= N_("E1171: Missing } after inline function"));
|
INIT(= N_("E1171: Missing } after inline function"));
|
||||||
EXTERN char e_cannot_use_default_values_in_lambda[]
|
EXTERN char e_cannot_use_default_values_in_lambda[]
|
||||||
INIT(= N_("E1172: Cannot use default values in a lambda"));
|
INIT(= N_("E1172: Cannot use default values in a lambda"));
|
||||||
|
EXTERN char e_text_found_after_enddef_str[]
|
||||||
|
INIT(= N_("E1173: Text found after enddef: %s"));
|
||||||
|
@@ -1961,6 +1961,11 @@ def Test_expr7_lambda_block()
|
|||||||
return 'no'
|
return 'no'
|
||||||
})
|
})
|
||||||
assert_equal(['no', 'yes', 'no'], dll)
|
assert_equal(['no', 'yes', 'no'], dll)
|
||||||
|
|
||||||
|
sandbox var Safe = (nr: number): number => {
|
||||||
|
return nr + 7
|
||||||
|
}
|
||||||
|
assert_equal(10, Safe(3))
|
||||||
END
|
END
|
||||||
CheckDefAndScriptSuccess(lines)
|
CheckDefAndScriptSuccess(lines)
|
||||||
|
|
||||||
@@ -1968,6 +1973,34 @@ def Test_expr7_lambda_block()
|
|||||||
map([1, 2], (k, v) => { redrawt })
|
map([1, 2], (k, v) => { redrawt })
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E488')
|
CheckDefAndScriptFailure(lines, 'E488')
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
var Func = (nr: int) => {
|
||||||
|
echo nr
|
||||||
|
}
|
||||||
|
END
|
||||||
|
CheckDefAndScriptFailure(lines, 'E1010', 1)
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
var Func = (nr: number): int => {
|
||||||
|
return nr
|
||||||
|
}
|
||||||
|
END
|
||||||
|
CheckDefAndScriptFailure(lines, 'E1010', 1)
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
var Func = (nr: number): int => {
|
||||||
|
return nr
|
||||||
|
END
|
||||||
|
CheckDefAndScriptFailure(lines, 'E1171', 1) # line nr is function start
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
var Func = (nr: number): int => {
|
||||||
|
var ll =<< ENDIT
|
||||||
|
nothing
|
||||||
|
END
|
||||||
|
CheckScriptFailure(lines, 'E1145: Missing heredoc end marker: ENDIT', 2)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def NewLambdaWithComments(): func
|
def NewLambdaWithComments(): func
|
||||||
|
@@ -86,6 +86,16 @@ def Test_endfunc_enddef()
|
|||||||
enddef
|
enddef
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1152:', 4)
|
CheckScriptFailure(lines, 'E1152:', 4)
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
def Ok()
|
||||||
|
echo 'hello'
|
||||||
|
enddef | echo 'there'
|
||||||
|
def Bad()
|
||||||
|
echo 'hello'
|
||||||
|
enddef there
|
||||||
|
END
|
||||||
|
CheckScriptFailure(lines, 'E1173: Text found after enddef: there', 6)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_missing_endfunc_enddef()
|
def Test_missing_endfunc_enddef()
|
||||||
|
@@ -731,13 +731,16 @@ get_function_body(
|
|||||||
else if (line_arg != NULL && *skipwhite(line_arg) != NUL)
|
else if (line_arg != NULL && *skipwhite(line_arg) != NUL)
|
||||||
nextcmd = line_arg;
|
nextcmd = line_arg;
|
||||||
else if (*p != NUL && *p != (vim9_function ? '#' : '"')
|
else if (*p != NUL && *p != (vim9_function ? '#' : '"')
|
||||||
&& p_verbose > 0
|
&& (vim9_function || p_verbose > 0))
|
||||||
&& eap->cmdidx != CMD_block)
|
{
|
||||||
give_warning2(eap->cmdidx == CMD_def
|
if (eap->cmdidx == CMD_def)
|
||||||
? (char_u *)_("W1001: Text found after :enddef: %s")
|
semsg(_(e_text_found_after_enddef_str), p);
|
||||||
: (char_u *)_("W22: Text found after :endfunction: %s"),
|
else
|
||||||
p, TRUE);
|
give_warning2((char_u *)
|
||||||
if (nextcmd != NULL)
|
_("W22: Text found after :endfunction: %s"),
|
||||||
|
p, TRUE);
|
||||||
|
}
|
||||||
|
if (nextcmd != NULL && *skipwhite(nextcmd) != NUL)
|
||||||
{
|
{
|
||||||
// Another command follows. If the line came from "eap"
|
// Another command follows. If the line came from "eap"
|
||||||
// we can simply point into it, otherwise we need to
|
// we can simply point into it, otherwise we need to
|
||||||
|
@@ -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 */
|
||||||
|
/**/
|
||||||
|
2645,
|
||||||
/**/
|
/**/
|
||||||
2644,
|
2644,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user