Mercurial > vim
comparison src/testdir/test_vim9_func.vim @ 24369:a97fb00978f6 v8.2.2725
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Commit: https://github.com/vim/vim/commit/e8c4660a55364a5d3e395652d1202b8702666823
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Apr 5 22:27:37 2021 +0200
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Problem: Vim9: message about compiling is wrong when using try/catch.
Solution: Store the compiling flag with the message. (closes https://github.com/vim/vim/issues/8071)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 05 Apr 2021 22:45:27 +0200 |
parents | beb395ca3e2f |
children | 2b4883926a24 |
comparison
equal
deleted
inserted
replaced
24368:4bf6a466ef7d | 24369:a97fb00978f6 |
---|---|
16 func Test_compiling_error() | 16 func Test_compiling_error() |
17 " use a terminal to see the whole error message | 17 " use a terminal to see the whole error message |
18 CheckRunVimInTerminal | 18 CheckRunVimInTerminal |
19 | 19 |
20 call TestCompilingError() | 20 call TestCompilingError() |
21 call TestCompilingErrorInTry() | |
21 endfunc | 22 endfunc |
22 | 23 |
23 def TestCompilingError() | 24 def TestCompilingError() |
24 var lines =<< trim END | 25 var lines =<< trim END |
25 vim9script | 26 vim9script |
26 def Fails() | 27 def Fails() |
27 echo nothing | 28 echo nothing |
28 enddef | 29 enddef |
29 defcompile | 30 defcompile |
30 END | 31 END |
31 call writefile(lines, 'XTest_compile_error') | 32 writefile(lines, 'XTest_compile_error') |
32 var buf = RunVimInTerminal('-S XTest_compile_error', | 33 var buf = RunVimInTerminal('-S XTest_compile_error', |
33 {rows: 10, wait_for_ruler: 0}) | 34 {rows: 10, wait_for_ruler: 0}) |
34 call WaitForAssert(() => assert_match('Error detected while compiling command line.*Fails.*Variable not found: nothing', | 35 WaitForAssert(() => assert_match('Error detected while compiling command line.*Fails.*Variable not found: nothing', |
35 Term_getlines(buf, range(1, 9)))) | 36 Term_getlines(buf, range(1, 9)))) |
36 | 37 |
37 # clean up | 38 # clean up |
38 call StopVimInTerminal(buf) | 39 StopVimInTerminal(buf) |
39 call delete('XTest_compile_error') | 40 delete('XTest_compile_error') |
41 enddef | |
42 | |
43 def TestCompilingErrorInTry() | |
44 var dir = 'Xdir/autoload' | |
45 mkdir(dir, 'p') | |
46 | |
47 var lines =<< trim END | |
48 vim9script | |
49 def script#OnlyCompiled() | |
50 g:runtime = 'yes' | |
51 invalid | |
52 enddef | |
53 END | |
54 writefile(lines, dir .. '/script.vim') | |
55 | |
56 lines =<< trim END | |
57 vim9script | |
58 todo | |
59 try | |
60 script#OnlyCompiled() | |
61 catch /nothing/ | |
62 endtry | |
63 END | |
64 lines[1] = 'set rtp=' .. getcwd() .. '/Xdir' | |
65 writefile(lines, 'XTest_compile_error') | |
66 | |
67 var buf = RunVimInTerminal('-S XTest_compile_error', {rows: 10, wait_for_ruler: 0}) | |
68 WaitForAssert(() => assert_match('Error detected while compiling command line.*function script#OnlyCompiled.*Invalid command: invalid', | |
69 Term_getlines(buf, range(1, 9)))) | |
70 | |
71 # clean up | |
72 StopVimInTerminal(buf) | |
73 delete('XTest_compile_error') | |
74 delete('Xdir', 'rf') | |
40 enddef | 75 enddef |
41 | 76 |
42 def CallRecursive(n: number): number | 77 def CallRecursive(n: number): number |
43 return CallRecursive(n + 1) | 78 return CallRecursive(n + 1) |
44 enddef | 79 enddef |