mirror of
https://github.com/vim/vim.git
synced 2025-09-04 21:33:48 -04:00
patch 8.2.1797: Vim9: some parts of the code not tested
Problem: Vim9: some parts of the code not tested. Solution: Add a few tests.
This commit is contained in:
parent
7b5d544269
commit
6abd3dc257
@ -1056,6 +1056,8 @@ def Test_func_type_part()
|
||||
CheckDefFailure(['var RefAny: func(): any', 'RefAny = FuncNoArgNoRet'], 'E1012: Type mismatch; expected func(): any but got func()')
|
||||
CheckDefFailure(['var RefAny: func(): any', 'RefAny = FuncOneArgNoRet'], 'E1012: Type mismatch; expected func(): any but got func(number)')
|
||||
|
||||
var RefAnyNoArgs: func: any = RefAny
|
||||
|
||||
var RefNr: func: number
|
||||
RefNr = FuncNoArgRetNumber
|
||||
RefNr = FuncOneArgRetNumber
|
||||
@ -1100,6 +1102,22 @@ def Test_func_return_type()
|
||||
CheckDefFailure(['var str: string', 'str = FuncNoArgRetNumber()'], 'E1012: Type mismatch; expected string but got number')
|
||||
enddef
|
||||
|
||||
def Test_func_common_type()
|
||||
def FuncOne(n: number): number
|
||||
return n
|
||||
enddef
|
||||
def FuncTwo(s: string): number
|
||||
return len(s)
|
||||
enddef
|
||||
def FuncThree(n: number, s: string): number
|
||||
return n + len(s)
|
||||
enddef
|
||||
var list = [FuncOne, FuncTwo, FuncThree]
|
||||
assert_equal(8, list[0](8))
|
||||
assert_equal(4, list[1]('word'))
|
||||
assert_equal(7, list[2](3, 'word'))
|
||||
enddef
|
||||
|
||||
def MultiLine(
|
||||
arg1: string,
|
||||
arg2 = 1234,
|
||||
@ -1948,6 +1966,9 @@ def Test_partial_call()
|
||||
Xsetlist = function('setqflist', [[], ' '])
|
||||
Xsetlist({'title': 'test'})
|
||||
getqflist({'title': 1})->assert_equal({'title': 'test'})
|
||||
|
||||
var Len: func: number = function('len', ['word'])
|
||||
assert_equal(4, Len())
|
||||
enddef
|
||||
|
||||
def Test_cmd_modifier()
|
||||
|
@ -750,6 +750,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1797,
|
||||
/**/
|
||||
1796,
|
||||
/**/
|
||||
|
Loading…
x
Reference in New Issue
Block a user