Mercurial > vim
diff src/testdir/test_vim9_expr.vim @ 21421:0f0fee4122d3 v8.2.1261
patch 8.2.1261: Vim9: common type of function not tested
Commit: https://github.com/vim/vim/commit/c7db57788b661a5da0b375d4fffdf10721550141
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jul 21 20:55:50 2020 +0200
patch 8.2.1261: Vim9: common type of function not tested
Problem: Vim9: common type of function not tested.
Solution: Add a test. Fix uncovered problems.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 21 Jul 2020 21:00:06 +0200 |
parents | e1aeb986712f |
children | a6c316ef161a |
line wrap: on
line diff
--- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -3,6 +3,15 @@ source check.vim source vim9.vim + +let g:cond = v:false +def FuncOne(arg: number): string + return 'yes' +enddef +def FuncTwo(arg: number): number + return 123 +enddef + " test cond ? expr : expr def Test_expr1() assert_equal('one', true ? 'one' : 'two') @@ -43,6 +52,11 @@ def Test_expr1() let RetTwo: func(string): number = function('winnr') let RetThat: func = g:atrue ? RetOne : RetTwo assert_equal(function('len'), RetThat) + + let x = FuncOne + let y = FuncTwo + let Z = g:cond ? FuncOne : FuncTwo + assert_equal(123, Z(3)) enddef def Test_expr1_vimscript() @@ -88,6 +102,13 @@ func Test_expr1_fails() call CheckDefFailure(["let x = 1 ? 'one': 'two'"], msg) call CheckDefFailure(["let x = 1 ? 'one' :'two'"], msg) call CheckDefFailure(["let x = 1 ? 'one':'two'"], msg) + + " missing argument detected even when common type is used + call CheckDefFailure([ + \ 'let x = FuncOne', + \ 'let y = FuncTwo', + \ 'let Z = g:cond ? FuncOne : FuncTwo', + \ 'Z()'], 'E119:') endfunc " TODO: define inside test function