Mercurial > vim
comparison src/testdir/test_vim9_func.vim @ 29970:d891115c0aea v9.0.0323
patch 9.0.0323: using common name in tests leads to flaky tests
Commit: https://github.com/vim/vim/commit/3b0d70f4ff436cb144683dafd956e8a3ee485a90
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Aug 29 22:31:20 2022 +0100
patch 9.0.0323: using common name in tests leads to flaky tests
Problem: Using common name in tests leads to flaky tests.
Solution: Rename files and directories to be more specific.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 29 Aug 2022 23:45:04 +0200 |
parents | 35cbea786334 |
children | 111d97d7b93a |
comparison
equal
deleted
inserted
replaced
29969:5f2d38cacd6c | 29970:d891115c0aea |
---|---|
39 g:StopVimInTerminal(buf) | 39 g:StopVimInTerminal(buf) |
40 delete('XTest_compile_error') | 40 delete('XTest_compile_error') |
41 enddef | 41 enddef |
42 | 42 |
43 def TestCompilingErrorInTry() | 43 def TestCompilingErrorInTry() |
44 var dir = 'Xdir/autoload' | 44 var dir = 'Xcompdir/autoload' |
45 mkdir(dir, 'p') | 45 mkdir(dir, 'p') |
46 | 46 |
47 var lines =<< trim END | 47 var lines =<< trim END |
48 vim9script | 48 vim9script |
49 export def OnlyCompiled() | 49 export def OnlyCompiled() |
59 try | 59 try |
60 script#OnlyCompiled() | 60 script#OnlyCompiled() |
61 catch /nothing/ | 61 catch /nothing/ |
62 endtry | 62 endtry |
63 END | 63 END |
64 lines[1] = 'set rtp=' .. getcwd() .. '/Xdir' | 64 lines[1] = 'set rtp=' .. getcwd() .. '/Xcompdir' |
65 writefile(lines, 'XTest_compile_error') | 65 writefile(lines, 'XTest_compile_error') |
66 | 66 |
67 var buf = g:RunVimInTerminal('-S XTest_compile_error', {rows: 10, wait_for_ruler: 0}) | 67 var buf = g:RunVimInTerminal('-S XTest_compile_error', {rows: 10, wait_for_ruler: 0}) |
68 g:WaitForAssert(() => assert_match('Error detected while compiling command line.*function script#OnlyCompiled.*Invalid command: invalid', | 68 g:WaitForAssert(() => assert_match('Error detected while compiling command line.*function script#OnlyCompiled.*Invalid command: invalid', |
69 g:Term_getlines(buf, range(1, 9)))) | 69 g:Term_getlines(buf, range(1, 9)))) |
70 | 70 |
71 # clean up | 71 # clean up |
72 g:StopVimInTerminal(buf) | 72 g:StopVimInTerminal(buf) |
73 delete('XTest_compile_error') | 73 delete('XTest_compile_error') |
74 delete('Xdir', 'rf') | 74 delete('Xcompdir', 'rf') |
75 enddef | 75 enddef |
76 | 76 |
77 def Test_comment_error() | 77 def Test_comment_error() |
78 v9.CheckDefFailure(['#{ comment'], 'E1170:') | 78 v9.CheckDefFailure(['#{ comment'], 'E1170:') |
79 enddef | 79 enddef |
168 v9.CheckScriptFailure(lines, 'E1182:') | 168 v9.CheckScriptFailure(lines, 'E1182:') |
169 delfunc g:Define | 169 delfunc g:Define |
170 enddef | 170 enddef |
171 | 171 |
172 def Test_autoload_name_mismatch() | 172 def Test_autoload_name_mismatch() |
173 var dir = 'Xdir/autoload' | 173 var dir = 'Xnamedir/autoload' |
174 mkdir(dir, 'p') | 174 mkdir(dir, 'p') |
175 | 175 |
176 var lines =<< trim END | 176 var lines =<< trim END |
177 vim9script | 177 vim9script |
178 export def NoFunction() | 178 export def NoFunction() |
181 enddef | 181 enddef |
182 END | 182 END |
183 writefile(lines, dir .. '/script.vim') | 183 writefile(lines, dir .. '/script.vim') |
184 | 184 |
185 var save_rtp = &rtp | 185 var save_rtp = &rtp |
186 exe 'set rtp=' .. getcwd() .. '/Xdir' | 186 exe 'set rtp=' .. getcwd() .. '/Xnamedir' |
187 lines =<< trim END | 187 lines =<< trim END |
188 call script#Function() | 188 call script#Function() |
189 END | 189 END |
190 v9.CheckScriptFailure(lines, 'E117:', 1) | 190 v9.CheckScriptFailure(lines, 'E117:', 1) |
191 | 191 |
192 &rtp = save_rtp | 192 &rtp = save_rtp |
193 delete(dir, 'rf') | 193 delete('Xnamdir', 'rf') |
194 enddef | 194 enddef |
195 | 195 |
196 def Test_autoload_names() | 196 def Test_autoload_names() |
197 var dir = 'Xdir/autoload' | 197 var dir = 'Xandir/autoload' |
198 mkdir(dir, 'p') | 198 mkdir(dir, 'p') |
199 | 199 |
200 var lines =<< trim END | 200 var lines =<< trim END |
201 func foobar#function() | 201 func foobar#function() |
202 return 'yes' | 202 return 'yes' |
204 let foobar#var = 'no' | 204 let foobar#var = 'no' |
205 END | 205 END |
206 writefile(lines, dir .. '/foobar.vim') | 206 writefile(lines, dir .. '/foobar.vim') |
207 | 207 |
208 var save_rtp = &rtp | 208 var save_rtp = &rtp |
209 exe 'set rtp=' .. getcwd() .. '/Xdir' | 209 exe 'set rtp=' .. getcwd() .. '/Xandir' |
210 | 210 |
211 lines =<< trim END | 211 lines =<< trim END |
212 assert_equal('yes', foobar#function()) | 212 assert_equal('yes', foobar#function()) |
213 var Function = foobar#function | 213 var Function = foobar#function |
214 assert_equal('yes', Function()) | 214 assert_equal('yes', Function()) |
216 assert_equal('no', foobar#var) | 216 assert_equal('no', foobar#var) |
217 END | 217 END |
218 v9.CheckDefAndScriptSuccess(lines) | 218 v9.CheckDefAndScriptSuccess(lines) |
219 | 219 |
220 &rtp = save_rtp | 220 &rtp = save_rtp |
221 delete(dir, 'rf') | 221 delete('Xandir', 'rf') |
222 enddef | 222 enddef |
223 | 223 |
224 def Test_autoload_error_in_script() | 224 def Test_autoload_error_in_script() |
225 var dir = 'Xdir/autoload' | 225 var dir = 'Xaedir/autoload' |
226 mkdir(dir, 'p') | 226 mkdir(dir, 'p') |
227 | 227 |
228 var lines =<< trim END | 228 var lines =<< trim END |
229 func scripterror#function() | 229 func scripterror#function() |
230 let g:called_function = 'yes' | 230 let g:called_function = 'yes' |
232 let 0 = 1 | 232 let 0 = 1 |
233 END | 233 END |
234 writefile(lines, dir .. '/scripterror.vim') | 234 writefile(lines, dir .. '/scripterror.vim') |
235 | 235 |
236 var save_rtp = &rtp | 236 var save_rtp = &rtp |
237 exe 'set rtp=' .. getcwd() .. '/Xdir' | 237 exe 'set rtp=' .. getcwd() .. '/Xaedir' |
238 | 238 |
239 g:called_function = 'no' | 239 g:called_function = 'no' |
240 # The error in the autoload script cannot be checked with assert_fails(), use | 240 # The error in the autoload script cannot be checked with assert_fails(), use |
241 # CheckDefSuccess() instead of CheckDefFailure() | 241 # CheckDefSuccess() instead of CheckDefFailure() |
242 try | 242 try |
262 v9.CheckDefSuccess(['scriptcaught#function()']) | 262 v9.CheckDefSuccess(['scriptcaught#function()']) |
263 assert_match('E121: Undefined variable: 0', g:caught) | 263 assert_match('E121: Undefined variable: 0', g:caught) |
264 assert_equal('yes', g:called_function) | 264 assert_equal('yes', g:called_function) |
265 | 265 |
266 &rtp = save_rtp | 266 &rtp = save_rtp |
267 delete(dir, 'rf') | 267 delete('Xaedir', 'rf') |
268 enddef | 268 enddef |
269 | 269 |
270 def s:CallRecursive(n: number): number | 270 def s:CallRecursive(n: number): number |
271 return CallRecursive(n + 1) | 271 return CallRecursive(n + 1) |
272 enddef | 272 enddef |