Mercurial > vim
comparison src/testdir/test_vim9_script.vim @ 19295:2a63b7f5802a v8.2.0206
patch 8.2.0206: calling Vim9 function using default argument fails
Commit: https://github.com/vim/vim/commit/26e117e9bcc09926d654b5993d61acde6b5749db
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Feb 4 21:24:15 2020 +0100
patch 8.2.0206: calling Vim9 function using default argument fails
Problem: Calling Vim9 function using default argument fails.
Solution: Give an appropriate error. (closes https://github.com/vim/vim/issues/5572)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 04 Feb 2020 21:30:04 +0100 |
parents | 86665583dc83 |
children | 84703c85a583 |
comparison
equal
deleted
inserted
replaced
19294:ce326aab4a79 | 19295:2a63b7f5802a |
---|---|
127 | 127 |
128 def Test_call_varargs() | 128 def Test_call_varargs() |
129 assert_equal('one', MyVarargs('one')) | 129 assert_equal('one', MyVarargs('one')) |
130 assert_equal('one,two', MyVarargs('one', 'two')) | 130 assert_equal('one,two', MyVarargs('one', 'two')) |
131 assert_equal('one,two,three', MyVarargs('one', 'two', 'three')) | 131 assert_equal('one,two,three', MyVarargs('one', 'two', 'three')) |
132 enddef | |
133 | |
134 "def Test_call_func_defined_later() | |
135 " call assert_equal('one', DefineLater('one')) | |
136 " call assert_fails('call NotDefined("one")', 'E99:') | |
137 "enddef | |
138 | |
139 func DefineLater(arg) | |
140 return a:arg | |
141 endfunc | |
142 | |
143 def MyDefaultArgs(name = 'string'): string | |
144 return name | |
145 enddef | |
146 | |
147 func Test_call_default_args_from_func() | |
148 " TODO: implement using default value for optional argument | |
149 "call assert_equal('string', MyDefaultArgs()) | |
150 call assert_fails('call MyDefaultArgs()', 'optional arguments not implemented yet') | |
151 call assert_equal('one', MyDefaultArgs('one')) | |
152 call assert_fails('call MyDefaultArgs("one", "two")', 'E118:') | |
153 endfunc | |
154 | |
155 def Test_call_default_args() | |
156 " TODO: implement using default value for optional argument | |
157 "assert_equal('string', MyDefaultArgs()) | |
158 assert_equal('one', MyDefaultArgs('one')) | |
159 assert_fails('call MyDefaultArgs("one", "two")', 'E118:') | |
132 enddef | 160 enddef |
133 | 161 |
134 def Test_return_type_wrong() | 162 def Test_return_type_wrong() |
135 " TODO: why is ! needed for Mac and FreeBSD? | 163 " TODO: why is ! needed for Mac and FreeBSD? |
136 CheckScriptFailure(['def Func(): number', 'return "a"', 'enddef'], 'expected number but got string') | 164 CheckScriptFailure(['def Func(): number', 'return "a"', 'enddef'], 'expected number but got string') |