Mercurial > vim
diff src/testdir/test_vim9_func.vim @ 19944:3055cd26e139 v8.2.0528
patch 8.2.0528: Vim9: function arguments insufficiently tested
Commit: https://github.com/vim/vim/commit/0b76b42d0a09fb6f1ed79cfc153da4edd6154c89
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Apr 7 22:05:08 2020 +0200
patch 8.2.0528: Vim9: function arguments insufficiently tested
Problem: Vim9: function arguments insufficiently tested.
Solution: Check types. Add more tests. Fix function with varargs only.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 07 Apr 2020 22:15:05 +0200 |
parents | b471038ec3ea |
children | 8466e62a2481 |
line wrap: on
line diff
--- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -130,6 +130,19 @@ def Test_call_def_varargs() assert_equal('one,two,three', MyDefVarargs('one', 'two', 'three')) enddef +" Only varargs +def MyVarargsOnly(...args: list<string>): string + return join(args, ',') +enddef + +def Test_call_varargs_only() + assert_equal('', MyVarargsOnly()) + assert_equal('one', MyVarargsOnly('one')) + assert_equal('one,two', MyVarargsOnly('one', 'two')) + call CheckDefFailure(['MyVarargsOnly(1)'], 'E1013: argument 1: type mismatch, expected string but got number') + call CheckDefFailure(['MyVarargsOnly("one", 2)'], 'E1013: argument 2: type mismatch, expected string but got number') +enddef + def Test_using_var_as_arg() call writefile(['def Func(x: number)', 'let x = 234', 'enddef'], 'Xdef') call assert_fails('so Xdef', 'E1006:')