Mercurial > vim
comparison src/testdir/test_vim9_script.vim @ 19530:48e71f948360 v8.2.0322
patch 8.2.0322: Vim9: error checks not tested
Commit: https://github.com/vim/vim/commit/b35efa5ed040162f5c988c71dfc1159045e47585
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Feb 26 20:15:18 2020 +0100
patch 8.2.0322: Vim9: error checks not tested
Problem: Vim9: error checks not tested.
Solution: Add more test cases. Avoid error for function loaded later.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 26 Feb 2020 20:30:09 +0100 |
parents | 3b026343f398 |
children | b8f778dda1a1 |
comparison
equal
deleted
inserted
replaced
19529:6f350fb85612 | 19530:48e71f948360 |
---|---|
176 call assert_equal('string', MyDefaultArgs()) | 176 call assert_equal('string', MyDefaultArgs()) |
177 call assert_equal('one', MyDefaultArgs('one')) | 177 call assert_equal('one', MyDefaultArgs('one')) |
178 call assert_fails('call MyDefaultArgs("one", "two")', 'E118:') | 178 call assert_fails('call MyDefaultArgs("one", "two")', 'E118:') |
179 endfunc | 179 endfunc |
180 | 180 |
181 func TakesOneArg(arg) | |
182 echo a:arg | |
183 endfunc | |
184 | |
185 def Test_call_wrong_arg_count() | |
186 call CheckDefFailure(['TakesOneArg()'], 'E119:') | |
187 call CheckDefFailure(['TakesOneArg(11, 22)'], 'E118:') | |
188 enddef | |
189 | |
181 " Default arg and varargs | 190 " Default arg and varargs |
182 def MyDefVarargs(one: string, two = 'foo', ...rest: list<string>): string | 191 def MyDefVarargs(one: string, two = 'foo', ...rest: list<string>): string |
183 let res = one .. ',' .. two | 192 let res = one .. ',' .. two |
184 for s in rest | 193 for s in rest |
185 res ..= ',' .. s | 194 res ..= ',' .. s |
192 assert_equal('one,foo', MyDefVarargs('one')) | 201 assert_equal('one,foo', MyDefVarargs('one')) |
193 assert_equal('one,two', MyDefVarargs('one', 'two')) | 202 assert_equal('one,two', MyDefVarargs('one', 'two')) |
194 assert_equal('one,two,three', MyDefVarargs('one', 'two', 'three')) | 203 assert_equal('one,two,three', MyDefVarargs('one', 'two', 'three')) |
195 enddef | 204 enddef |
196 | 205 |
197 | 206 def Test_call_func_defined_later() |
198 "def Test_call_func_defined_later() | 207 call assert_equal('one', DefinedLater('one')) |
199 " call assert_equal('one', DefineLater('one')) | 208 call assert_fails('call NotDefined("one")', 'E117:') |
200 " call assert_fails('call NotDefined("one")', 'E99:') | 209 enddef |
201 "enddef | 210 |
202 | 211 func DefinedLater(arg) |
203 func DefineLater(arg) | |
204 return a:arg | 212 return a:arg |
205 endfunc | 213 endfunc |
206 | 214 |
207 def Test_return_type_wrong() | 215 def Test_return_type_wrong() |
208 CheckScriptFailure(['def Func(): number', 'return "a"', 'enddef'], 'expected number but got string') | 216 CheckScriptFailure(['def Func(): number', 'return "a"', 'enddef'], 'expected number but got string') |