comparison src/testdir/test_profile.vim @ 16720:9c90cf08cfa8 v8.1.1362

patch 8.1.1362: code and data in tests can be hard to read commit https://github.com/vim/vim/commit/c79745a82faeb5a6058e915ca49a4c69fa60ea01 Author: Bram Moolenaar <Bram@vim.org> Date: Mon May 20 22:12:34 2019 +0200 patch 8.1.1362: code and data in tests can be hard to read Problem: Code and data in tests can be hard to read. Solution: Use the new heredoc style. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/4400)
author Bram Moolenaar <Bram@vim.org>
date Mon, 20 May 2019 22:15:06 +0200
parents 2dcaa860e3fc
children f38fcbf343ce
comparison
equal deleted inserted replaced
16719:27f2a2799604 16720:9c90cf08cfa8
2 if !has('profile') 2 if !has('profile')
3 finish 3 finish
4 endif 4 endif
5 5
6 func Test_profile_func() 6 func Test_profile_func()
7 let lines = [ 7 let lines =<< trim [CODE]
8 \ 'profile start Xprofile_func.log', 8 profile start Xprofile_func.log
9 \ 'profile func Foo*"', 9 profile func Foo*
10 \ "func! Foo1()", 10 func! Foo1()
11 \ "endfunc", 11 endfunc
12 \ "func! Foo2()", 12 func! Foo2()
13 \ " let l:count = 100", 13 let l:count = 100
14 \ " while l:count > 0", 14 while l:count > 0
15 \ " let l:count = l:count - 1", 15 let l:count = l:count - 1
16 \ " endwhile", 16 endwhile
17 \ "endfunc", 17 endfunc
18 \ "func! Foo3()", 18 func! Foo3()
19 \ "endfunc", 19 endfunc
20 \ "func! Bar()", 20 func! Bar()
21 \ "endfunc", 21 endfunc
22 \ "call Foo1()", 22 call Foo1()
23 \ "call Foo1()", 23 call Foo1()
24 \ "profile pause", 24 profile pause
25 \ "call Foo1()", 25 call Foo1()
26 \ "profile continue", 26 profile continue
27 \ "call Foo2()", 27 call Foo2()
28 \ "call Foo3()", 28 call Foo3()
29 \ "call Bar()", 29 call Bar()
30 \ "if !v:profiling", 30 if !v:profiling
31 \ " delfunc Foo2", 31 delfunc Foo2
32 \ "endif", 32 endif
33 \ "delfunc Foo3", 33 delfunc Foo3
34 \ ] 34 [CODE]
35 35
36 call writefile(lines, 'Xprofile_func.vim') 36 call writefile(lines, 'Xprofile_func.vim')
37 call system(v:progpath 37 call system(v:progpath
38 \ . ' -es --clean' 38 \ . ' -es --clean'
39 \ . ' -c "so Xprofile_func.vim"' 39 \ . ' -c "so Xprofile_func.vim"'
84 call delete('Xprofile_func.vim') 84 call delete('Xprofile_func.vim')
85 call delete('Xprofile_func.log') 85 call delete('Xprofile_func.log')
86 endfunc 86 endfunc
87 87
88 func Test_profile_func_with_ifelse() 88 func Test_profile_func_with_ifelse()
89 let lines = [ 89 let lines =<< trim [CODE]
90 \ "func! Foo1()", 90 func! Foo1()
91 \ " if 1", 91 if 1
92 \ " let x = 0", 92 let x = 0
93 \ " elseif 1", 93 elseif 1
94 \ " let x = 1", 94 let x = 1
95 \ " else", 95 else
96 \ " let x = 2", 96 let x = 2
97 \ " endif", 97 endif
98 \ "endfunc", 98 endfunc
99 \ "func! Foo2()", 99 func! Foo2()
100 \ " if 0", 100 if 0
101 \ " let x = 0", 101 let x = 0
102 \ " elseif 1", 102 elseif 1
103 \ " let x = 1", 103 let x = 1
104 \ " else", 104 else
105 \ " let x = 2", 105 let x = 2
106 \ " endif", 106 endif
107 \ "endfunc", 107 endfunc
108 \ "func! Foo3()", 108 func! Foo3()
109 \ " if 0", 109 if 0
110 \ " let x = 0", 110 let x = 0
111 \ " elseif 0", 111 elseif 0
112 \ " let x = 1", 112 let x = 1
113 \ " else", 113 else
114 \ " let x = 2", 114 let x = 2
115 \ " endif", 115 endif
116 \ "endfunc", 116 endfunc
117 \ "call Foo1()", 117 call Foo1()
118 \ "call Foo2()", 118 call Foo2()
119 \ "call Foo3()", 119 call Foo3()
120 \ ] 120 [CODE]
121 121
122 call writefile(lines, 'Xprofile_func.vim') 122 call writefile(lines, 'Xprofile_func.vim')
123 call system(v:progpath 123 call system(v:progpath
124 \ . ' -es -u NONE -U NONE -i NONE --noplugin' 124 \ . ' -es -u NONE -U NONE -i NONE --noplugin'
125 \ . ' -c "profile start Xprofile_func.log"' 125 \ . ' -c "profile start Xprofile_func.log"'
194 call delete('Xprofile_func.vim') 194 call delete('Xprofile_func.vim')
195 call delete('Xprofile_func.log') 195 call delete('Xprofile_func.log')
196 endfunc 196 endfunc
197 197
198 func Test_profile_func_with_trycatch() 198 func Test_profile_func_with_trycatch()
199 let lines = [ 199 let lines =<< trim [CODE]
200 \ "func! Foo1()", 200 func! Foo1()
201 \ " try", 201 try
202 \ " let x = 0", 202 let x = 0
203 \ " catch", 203 catch
204 \ " let x = 1", 204 let x = 1
205 \ " finally", 205 finally
206 \ " let x = 2", 206 let x = 2
207 \ " endtry", 207 endtry
208 \ "endfunc", 208 endfunc
209 \ "func! Foo2()", 209 func! Foo2()
210 \ " try", 210 try
211 \ " throw 0", 211 throw 0
212 \ " catch", 212 catch
213 \ " let x = 1", 213 let x = 1
214 \ " finally", 214 finally
215 \ " let x = 2", 215 let x = 2
216 \ " endtry", 216 endtry
217 \ "endfunc", 217 endfunc
218 \ "func! Foo3()", 218 func! Foo3()
219 \ " try", 219 try
220 \ " throw 0", 220 throw 0
221 \ " catch", 221 catch
222 \ " throw 1", 222 throw 1
223 \ " finally", 223 finally
224 \ " let x = 2", 224 let x = 2
225 \ " endtry", 225 endtry
226 \ "endfunc", 226 endfunc
227 \ "call Foo1()", 227 call Foo1()
228 \ "call Foo2()", 228 call Foo2()
229 \ "try", 229 try
230 \ " call Foo3()", 230 call Foo3()
231 \ "catch", 231 catch
232 \ "endtry", 232 endtry
233 \ ] 233 [CODE]
234 234
235 call writefile(lines, 'Xprofile_func.vim') 235 call writefile(lines, 'Xprofile_func.vim')
236 call system(v:progpath 236 call system(v:progpath
237 \ . ' -es -u NONE -U NONE -i NONE --noplugin' 237 \ . ' -es -u NONE -U NONE -i NONE --noplugin'
238 \ . ' -c "profile start Xprofile_func.log"' 238 \ . ' -c "profile start Xprofile_func.log"'
307 call delete('Xprofile_func.vim') 307 call delete('Xprofile_func.vim')
308 call delete('Xprofile_func.log') 308 call delete('Xprofile_func.log')
309 endfunc 309 endfunc
310 310
311 func Test_profile_file() 311 func Test_profile_file()
312 let lines = [ 312 let lines =<< trim [CODE]
313 \ 'func! Foo()', 313 func! Foo()
314 \ 'endfunc', 314 endfunc
315 \ 'for i in range(10)', 315 for i in range(10)
316 \ ' " a comment', 316 " a comment
317 \ ' call Foo()', 317 call Foo()
318 \ 'endfor', 318 endfor
319 \ 'call Foo()', 319 call Foo()
320 \ ] 320 [CODE]
321 321
322 call writefile(lines, 'Xprofile_file.vim') 322 call writefile(lines, 'Xprofile_file.vim')
323 call system(v:progpath 323 call system(v:progpath
324 \ . ' -es --clean' 324 \ . ' -es --clean'
325 \ . ' -c "profile start Xprofile_file.log"' 325 \ . ' -c "profile start Xprofile_file.log"'
446 call delete('Xprofile_file.vim') 446 call delete('Xprofile_file.vim')
447 call delete('Xprofile_file.log') 447 call delete('Xprofile_file.log')
448 endfunc 448 endfunc
449 449
450 func Test_profdel_func() 450 func Test_profdel_func()
451 let lines = [ 451 let lines =<< trim [CODE]
452 \ 'profile start Xprofile_file.log', 452 profile start Xprofile_file.log
453 \ 'func! Foo1()', 453 func! Foo1()
454 \ 'endfunc', 454 endfunc
455 \ 'func! Foo2()', 455 func! Foo2()
456 \ 'endfunc', 456 endfunc
457 \ 'func! Foo3()', 457 func! Foo3()
458 \ 'endfunc', 458 endfunc
459 \ '', 459
460 \ 'profile func Foo1', 460 profile func Foo1
461 \ 'profile func Foo2', 461 profile func Foo2
462 \ 'call Foo1()', 462 call Foo1()
463 \ 'call Foo2()', 463 call Foo2()
464 \ '', 464
465 \ 'profile func Foo3', 465 profile func Foo3
466 \ 'profdel func Foo2', 466 profdel func Foo2
467 \ 'profdel func Foo3', 467 profdel func Foo3
468 \ 'call Foo1()', 468 call Foo1()
469 \ 'call Foo2()', 469 call Foo2()
470 \ 'call Foo3()' ] 470 call Foo3()
471 [CODE]
471 call writefile(lines, 'Xprofile_file.vim') 472 call writefile(lines, 'Xprofile_file.vim')
472 call system(v:progpath . ' -es --clean -c "so Xprofile_file.vim" -c q') 473 call system(v:progpath . ' -es --clean -c "so Xprofile_file.vim" -c q')
473 call assert_equal(0, v:shell_error) 474 call assert_equal(0, v:shell_error)
474 475
475 let lines = readfile('Xprofile_file.log') 476 let lines = readfile('Xprofile_file.log')
492 endfunc 493 endfunc
493 494
494 func Test_profdel_star() 495 func Test_profdel_star()
495 " Foo() is invoked once before and once after 'profdel *'. 496 " Foo() is invoked once before and once after 'profdel *'.
496 " So profiling should report it only once. 497 " So profiling should report it only once.
497 let lines = [ 498 let lines =<< trim [CODE]
498 \ 'profile start Xprofile_file.log', 499 profile start Xprofile_file.log
499 \ 'func! Foo()', 500 func! Foo()
500 \ 'endfunc', 501 endfunc
501 \ 'profile func Foo', 502 profile func Foo
502 \ 'call Foo()', 503 call Foo()
503 \ 'profdel *', 504 profdel *
504 \ 'call Foo()' ] 505 call Foo()
506 [CODE]
505 call writefile(lines, 'Xprofile_file.vim') 507 call writefile(lines, 'Xprofile_file.vim')
506 call system(v:progpath . ' -es --clean -c "so Xprofile_file.vim" -c q') 508 call system(v:progpath . ' -es --clean -c "so Xprofile_file.vim" -c q')
507 call assert_equal(0, v:shell_error) 509 call assert_equal(0, v:shell_error)
508 510
509 let lines = readfile('Xprofile_file.log') 511 let lines = readfile('Xprofile_file.log')