comparison src/testdir/test_messages.vim @ 30582:72245f9c9405 v9.0.0626

patch 9.0.0626: too many delete() calls in tests Commit: https://github.com/vim/vim/commit/b152b6a40f729ed81a25d2fa541a4e73e201bec4 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Sep 29 21:37:33 2022 +0100 patch 9.0.0626: too many delete() calls in tests Problem: Too many delete() calls in tests. Solution: Use deferred delete where possible.
author Bram Moolenaar <Bram@vim.org>
date Thu, 29 Sep 2022 22:45:04 +0200
parents a1b4d1dae6b1
children d914a3812d5b
comparison
equal deleted inserted replaced
30581:2e1ec75a7766 30582:72245f9c9405
101 return "" 101 return ""
102 endfunc 102 endfunc
103 set statusline=%!StatusLine() 103 set statusline=%!StatusLine()
104 set laststatus=2 104 set laststatus=2
105 END 105 END
106 call writefile(lines, testfile) 106 call writefile(lines, testfile, 'D')
107 107
108 let rows = 10 108 let rows = 10
109 let buf = term_start([GetVimProg(), '--clean', '-S', testfile], {'term_rows': rows}) 109 let buf = term_start([GetVimProg(), '--clean', '-S', testfile], {'term_rows': rows})
110 call TermWait(buf, 100) 110 call TermWait(buf, 100)
111 call assert_equal('run', job_status(term_getjob(buf))) 111 call assert_equal('run', job_status(term_getjob(buf)))
115 call term_sendkeys(buf, "\<C-C>") 115 call term_sendkeys(buf, "\<C-C>")
116 call WaitForAssert({-> assert_match('^\s*$', term_getline(buf, rows))}) 116 call WaitForAssert({-> assert_match('^\s*$', term_getline(buf, rows))})
117 117
118 call term_sendkeys(buf, ":qall!\<CR>") 118 call term_sendkeys(buf, ":qall!\<CR>")
119 call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(buf)))}) 119 call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(buf)))})
120
120 exe buf . 'bwipe!' 121 exe buf . 'bwipe!'
121 call delete(testfile)
122 endfunc 122 endfunc
123 123
124 func Test_mode_message_at_leaving_insert_with_esc_mapped() 124 func Test_mode_message_at_leaving_insert_with_esc_mapped()
125 CheckFeature terminal 125 CheckFeature terminal
126 CheckNotGui 126 CheckNotGui
129 let testfile = 'Xtest.vim' 129 let testfile = 'Xtest.vim'
130 let lines =<< trim END 130 let lines =<< trim END
131 set laststatus=2 131 set laststatus=2
132 inoremap <Esc> <Esc>00 132 inoremap <Esc> <Esc>00
133 END 133 END
134 call writefile(lines, testfile) 134 call writefile(lines, testfile, 'D')
135 135
136 let rows = 10 136 let rows = 10
137 let buf = term_start([GetVimProg(), '--clean', '-S', testfile], {'term_rows': rows}) 137 let buf = term_start([GetVimProg(), '--clean', '-S', testfile], {'term_rows': rows})
138 call WaitForAssert({-> assert_match('0,0-1\s*All$', term_getline(buf, rows - 1))}) 138 call WaitForAssert({-> assert_match('0,0-1\s*All$', term_getline(buf, rows - 1))})
139 call assert_equal('run', job_status(term_getjob(buf))) 139 call assert_equal('run', job_status(term_getjob(buf)))
143 call term_sendkeys(buf, "\<Esc>") 143 call term_sendkeys(buf, "\<Esc>")
144 call WaitForAssert({-> assert_match('^\s*$', term_getline(buf, rows))}) 144 call WaitForAssert({-> assert_match('^\s*$', term_getline(buf, rows))})
145 145
146 call term_sendkeys(buf, ":qall!\<CR>") 146 call term_sendkeys(buf, ":qall!\<CR>")
147 call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(buf)))}) 147 call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(buf)))})
148
148 exe buf . 'bwipe!' 149 exe buf . 'bwipe!'
149 call delete(testfile)
150 endfunc 150 endfunc
151 151
152 func Test_echospace() 152 func Test_echospace()
153 set noruler noshowcmd laststatus=1 153 set noruler noshowcmd laststatus=1
154 call assert_equal(&columns - 1, v:echospace) 154 call assert_equal(&columns - 1, v:echospace)
460 hide buffer a.txt 460 hide buffer a.txt
461 461
462 autocmd CursorHold * buf b.txt | w | echo "'b' written" 462 autocmd CursorHold * buf b.txt | w | echo "'b' written"
463 END 463 END
464 464
465 call writefile(content, 'Xtest_fileinfo_after_echo') 465 call writefile(content, 'Xtest_fileinfo_after_echo', 'D')
466 let buf = RunVimInTerminal('-S Xtest_fileinfo_after_echo', #{rows: 6}) 466 let buf = RunVimInTerminal('-S Xtest_fileinfo_after_echo', #{rows: 6})
467 call term_sendkeys(buf, ":set updatetime=50\<CR>") 467 call term_sendkeys(buf, ":set updatetime=50\<CR>")
468 call term_sendkeys(buf, "0$") 468 call term_sendkeys(buf, "0$")
469 call VerifyScreenDump(buf, 'Test_fileinfo_after_echo', {}) 469 call VerifyScreenDump(buf, 'Test_fileinfo_after_echo', {})
470 470
471 call term_sendkeys(buf, ":q\<CR>") 471 call term_sendkeys(buf, ":q\<CR>")
472 472
473 " clean up 473 " clean up
474 call StopVimInTerminal(buf) 474 call StopVimInTerminal(buf)
475 call delete('Xtest_fileinfo_after_echo')
476 call delete('b.txt') 475 call delete('b.txt')
477 endfunc 476 endfunc
478 477
479 func Test_echowindow() 478 func Test_echowindow()
480 CheckScreendump 479 CheckScreendump
511 echo 'one' 510 echo 'one'
512 echo 'two' 511 echo 'two'
513 echo 'three' 512 echo 'three'
514 enddef 513 enddef
515 END 514 END
516 call writefile(lines, 'XtestEchowindow') 515 call writefile(lines, 'XtestEchowindow', 'D')
517 let buf = RunVimInTerminal('-S XtestEchowindow', #{rows: 8}) 516 let buf = RunVimInTerminal('-S XtestEchowindow', #{rows: 8})
518 call VerifyScreenDump(buf, 'Test_echowindow_1', {}) 517 call VerifyScreenDump(buf, 'Test_echowindow_1', {})
519 518
520 call term_sendkeys(buf, ":call ShowMessage('second line')\<CR>") 519 call term_sendkeys(buf, ":call ShowMessage('second line')\<CR>")
521 call VerifyScreenDump(buf, 'Test_echowindow_2', {}) 520 call VerifyScreenDump(buf, 'Test_echowindow_2', {})
540 call term_sendkeys(buf, ":echowin 'more'\<CR>") 539 call term_sendkeys(buf, ":echowin 'more'\<CR>")
541 call VerifyScreenDump(buf, 'Test_echowindow_8', {}) 540 call VerifyScreenDump(buf, 'Test_echowindow_8', {})
542 541
543 " clean up 542 " clean up
544 call StopVimInTerminal(buf) 543 call StopVimInTerminal(buf)
545 call delete('XtestEchowindow')
546 endfunc 544 endfunc
547 545
548 " messages window should not be used while evaluating the :echowin argument 546 " messages window should not be used while evaluating the :echowin argument
549 func Test_echowin_eval() 547 func Test_echowin_eval()
550 CheckScreendump 548 CheckScreendump
554 echo 123 552 echo 123
555 return 'test' 553 return 'test'
556 endfunc 554 endfunc
557 echowindow ShowMessage() 555 echowindow ShowMessage()
558 END 556 END
559 call writefile(lines, 'XtestEchowindow') 557 call writefile(lines, 'XtestEchowindow', 'D')
560 let buf = RunVimInTerminal('-S XtestEchowindow', #{rows: 8}) 558 let buf = RunVimInTerminal('-S XtestEchowindow', #{rows: 8})
561 call VerifyScreenDump(buf, 'Test_echowin_eval', {}) 559 call VerifyScreenDump(buf, 'Test_echowin_eval', {})
562 560
563 " clean up 561 " clean up
564 call StopVimInTerminal(buf) 562 call StopVimInTerminal(buf)
565 call delete('XtestEchowindow')
566 endfunc 563 endfunc
567 564
568 " messages window should not be used for showing the mode 565 " messages window should not be used for showing the mode
569 func Test_echowin_showmode() 566 func Test_echowin_showmode()
570 CheckScreendump 567 CheckScreendump