mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.4404: Vim9: some code not covered by tests
Problem: Vim9: some code not covered by tests. Solution: Add a few specific test cases.
This commit is contained in:
parent
9437737833
commit
cd1cda2f87
@ -3226,6 +3226,14 @@ def Test_partial_call()
|
|||||||
v9.CheckScriptFailure(lines, 'E1235:')
|
v9.CheckScriptFailure(lines, 'E1235:')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_partial_double_nested()
|
||||||
|
var idx = 123
|
||||||
|
var Get = () => idx
|
||||||
|
var Ref = function(Get, [])
|
||||||
|
var RefRef = function(Ref, [])
|
||||||
|
assert_equal(123, RefRef())
|
||||||
|
enddef
|
||||||
|
|
||||||
" Using "idx" from a legacy global function does not work.
|
" Using "idx" from a legacy global function does not work.
|
||||||
" This caused a crash when called from legacy context.
|
" This caused a crash when called from legacy context.
|
||||||
func Test_partial_call_fails()
|
func Test_partial_call_fails()
|
||||||
|
@ -1185,6 +1185,137 @@ def Test_vim9_reload_noclear()
|
|||||||
delete('XreloadScript.vim')
|
delete('XreloadScript.vim')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_vim_reload_noclear_arg_count()
|
||||||
|
var lines =<< trim END
|
||||||
|
vim9script noclear
|
||||||
|
|
||||||
|
if !exists('g:didload')
|
||||||
|
def Test(a: string, b: string)
|
||||||
|
echo a b
|
||||||
|
enddef
|
||||||
|
def Call()
|
||||||
|
Test('a', 'b')
|
||||||
|
enddef
|
||||||
|
else
|
||||||
|
# redefine with one argument less
|
||||||
|
def Test(a: string)
|
||||||
|
echo a
|
||||||
|
enddef
|
||||||
|
endif
|
||||||
|
Call()
|
||||||
|
g:didload = 1
|
||||||
|
END
|
||||||
|
lines->writefile('XreloadScript_1.vim')
|
||||||
|
source XreloadScript_1.vim
|
||||||
|
assert_fails('source XreloadScript_1.vim', 'E1106: One argument too many')
|
||||||
|
unlet g:didload
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script noclear
|
||||||
|
|
||||||
|
if !exists('g:didload')
|
||||||
|
def Test(a: string, b: string, c: string)
|
||||||
|
echo a b
|
||||||
|
enddef
|
||||||
|
def Call()
|
||||||
|
Test('a', 'b', 'c')
|
||||||
|
enddef
|
||||||
|
else
|
||||||
|
# redefine with one argument less
|
||||||
|
def Test(a: string)
|
||||||
|
echo a
|
||||||
|
enddef
|
||||||
|
endif
|
||||||
|
Call()
|
||||||
|
g:didload = 1
|
||||||
|
END
|
||||||
|
lines->writefile('XreloadScript_2.vim')
|
||||||
|
source XreloadScript_2.vim
|
||||||
|
assert_fails('source XreloadScript_2.vim', 'E1106: 2 arguments too many')
|
||||||
|
unlet g:didload
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script noclear
|
||||||
|
|
||||||
|
if !exists('g:didload')
|
||||||
|
def Test(a: string)
|
||||||
|
echo a
|
||||||
|
enddef
|
||||||
|
def Call()
|
||||||
|
Test('a')
|
||||||
|
enddef
|
||||||
|
else
|
||||||
|
# redefine with one argument extra
|
||||||
|
def Test(a: string, b: string)
|
||||||
|
echo a b
|
||||||
|
enddef
|
||||||
|
endif
|
||||||
|
Call()
|
||||||
|
g:didload = 1
|
||||||
|
END
|
||||||
|
lines->writefile('XreloadScript_3.vim')
|
||||||
|
source XreloadScript_3.vim
|
||||||
|
assert_fails('source XreloadScript_3.vim', 'E1190: One argument too few')
|
||||||
|
unlet g:didload
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script noclear
|
||||||
|
|
||||||
|
if !exists('g:didload')
|
||||||
|
def Test(a: string)
|
||||||
|
echo a
|
||||||
|
enddef
|
||||||
|
def Call()
|
||||||
|
Test('a')
|
||||||
|
enddef
|
||||||
|
else
|
||||||
|
# redefine with two arguments extra
|
||||||
|
def Test(a: string, b: string, c: string)
|
||||||
|
echo a b
|
||||||
|
enddef
|
||||||
|
endif
|
||||||
|
Call()
|
||||||
|
g:didload = 1
|
||||||
|
END
|
||||||
|
lines->writefile('XreloadScript_4.vim')
|
||||||
|
source XreloadScript_4.vim
|
||||||
|
assert_fails('source XreloadScript_4.vim', 'E1190: 2 arguments too few')
|
||||||
|
unlet g:didload
|
||||||
|
|
||||||
|
delete('XreloadScript_1.vim')
|
||||||
|
delete('XreloadScript_2.vim')
|
||||||
|
delete('XreloadScript_3.vim')
|
||||||
|
delete('XreloadScript_4.vim')
|
||||||
|
enddef
|
||||||
|
|
||||||
|
def Test_vim9_reload_noclear_error()
|
||||||
|
var lines =<< trim END
|
||||||
|
vim9script noclear
|
||||||
|
|
||||||
|
if !exists('g:didload')
|
||||||
|
def Test(a: string)
|
||||||
|
echo a
|
||||||
|
enddef
|
||||||
|
def Call()
|
||||||
|
Test('a')
|
||||||
|
enddef
|
||||||
|
else
|
||||||
|
# redefine with a compile error
|
||||||
|
def Test(a: string)
|
||||||
|
echo ax
|
||||||
|
enddef
|
||||||
|
endif
|
||||||
|
Call()
|
||||||
|
g:didload = 1
|
||||||
|
END
|
||||||
|
lines->writefile('XreloadScriptErr.vim')
|
||||||
|
source XreloadScriptErr.vim
|
||||||
|
assert_fails('source XreloadScriptErr.vim', 'E1001: Variable not found: ax')
|
||||||
|
|
||||||
|
unlet g:didload
|
||||||
|
delete('XreloadScriptErr.vim')
|
||||||
|
enddef
|
||||||
|
|
||||||
def Test_vim9_reload_import()
|
def Test_vim9_reload_import()
|
||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
|
@ -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 */
|
||||||
|
/**/
|
||||||
|
4404,
|
||||||
/**/
|
/**/
|
||||||
4403,
|
4403,
|
||||||
/**/
|
/**/
|
||||||
|
@ -367,6 +367,16 @@ call_dfunc(
|
|||||||
semsg(_(e_nr_arguments_too_many), -arg_to_add);
|
semsg(_(e_nr_arguments_too_many), -arg_to_add);
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
else if (arg_to_add > ufunc->uf_def_args.ga_len)
|
||||||
|
{
|
||||||
|
int missing = arg_to_add - ufunc->uf_def_args.ga_len;
|
||||||
|
|
||||||
|
if (missing == 1)
|
||||||
|
emsg(_(e_one_argument_too_few));
|
||||||
|
else
|
||||||
|
semsg(_(e_nr_arguments_too_few), missing);
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
// Reserve space for:
|
// Reserve space for:
|
||||||
// - missing arguments
|
// - missing arguments
|
||||||
|
Loading…
x
Reference in New Issue
Block a user