Mercurial > vim
comparison src/testdir/test_vim9_func.vim @ 19932:2c4d9ca33769 v8.2.0522
patch 8.2.0522: several errors are not tested for
Commit: https://github.com/vim/vim/commit/ee4e0c1e9a81cb5d96e0060203a9033c2f28588e
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Apr 6 21:35:05 2020 +0200
patch 8.2.0522: several errors are not tested for
Problem: Several errors are not tested for.
Solution: Add tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5892)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 06 Apr 2020 21:45:31 +0200 |
parents | d286bfc44149 |
children | b471038ec3ea |
comparison
equal
deleted
inserted
replaced
19931:db6b095f4073 | 19932:2c4d9ca33769 |
---|---|
166 | 166 |
167 CheckScriptFailure(['def Func(): number', 'return', 'enddef'], 'E1003:') | 167 CheckScriptFailure(['def Func(): number', 'return', 'enddef'], 'E1003:') |
168 | 168 |
169 CheckScriptFailure(['def Func(): list', 'return []', 'enddef'], 'E1008:') | 169 CheckScriptFailure(['def Func(): list', 'return []', 'enddef'], 'E1008:') |
170 CheckScriptFailure(['def Func(): dict', 'return {}', 'enddef'], 'E1008:') | 170 CheckScriptFailure(['def Func(): dict', 'return {}', 'enddef'], 'E1008:') |
171 CheckScriptFailure(['def Func()', 'return 1'], 'E1057:') | |
171 enddef | 172 enddef |
172 | 173 |
173 def Test_arg_type_wrong() | 174 def Test_arg_type_wrong() |
174 CheckScriptFailure(['def Func3(items: list)', 'echo "a"', 'enddef'], 'E1008: Missing <type>') | 175 CheckScriptFailure(['def Func3(items: list)', 'echo "a"', 'enddef'], 'E1008: Missing <type>') |
176 CheckScriptFailure(['def Func4(...)', 'echo "a"', 'enddef'], 'E1055: Missing name after ...') | |
175 enddef | 177 enddef |
176 | 178 |
177 def Test_vim9script_call() | 179 def Test_vim9script_call() |
178 let lines =<< trim END | 180 let lines =<< trim END |
179 vim9script | 181 vim9script |
434 assert_equal('yes', str) | 436 assert_equal('yes', str) |
435 | 437 |
436 CheckDefFailure(['let str: string', 'str = FuncNoArgRetNumber()'], 'E1013: type mismatch, expected string but got number') | 438 CheckDefFailure(['let str: string', 'str = FuncNoArgRetNumber()'], 'E1013: type mismatch, expected string but got number') |
437 enddef | 439 enddef |
438 | 440 |
441 " When using CheckScriptFailure() for the below test, E1010 is generated instead | |
442 " of E1056. | |
443 func Test_E1056_1059() | |
444 let caught_1056 = 0 | |
445 try | |
446 def F(): | |
447 return 1 | |
448 enddef | |
449 catch /E1056:/ | |
450 let caught_1056 = 1 | |
451 endtry | |
452 call assert_equal(1, caught_1056) | |
453 | |
454 let caught_1059 = 0 | |
455 try | |
456 def F5(items : list) | |
457 echo 'a' | |
458 enddef | |
459 catch /E1059:/ | |
460 let caught_1059 = 1 | |
461 endtry | |
462 call assert_equal(1, caught_1059) | |
463 endfunc | |
439 | 464 |
440 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker | 465 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |