comparison src/testdir/test_normal.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 13b02c1ea0f7
children 4fbd9086f149
comparison
equal deleted inserted replaced
30581:2e1ec75a7766 30582:72245f9c9405
297 func Test_normal06_formatprg() 297 func Test_normal06_formatprg()
298 " only test on non windows platform 298 " only test on non windows platform
299 CheckNotMSWindows 299 CheckNotMSWindows
300 300
301 " uses sed to number non-empty lines 301 " uses sed to number non-empty lines
302 call writefile(['#!/bin/sh', 'sed ''/./=''|sed ''/./{', 'N', 's/\n/ /', '}'''], 'Xsed_format.sh') 302 call writefile(['#!/bin/sh', 'sed ''/./=''|sed ''/./{', 'N', 's/\n/ /', '}'''], 'Xsed_format.sh', 'D')
303 call system('chmod +x ./Xsed_format.sh') 303 call system('chmod +x ./Xsed_format.sh')
304 let text = ['a', '', 'c', '', ' ', 'd', 'e'] 304 let text = ['a', '', 'c', '', ' ', 'd', 'e']
305 let expected = ['1 a', '', '3 c', '', '5 ', '6 d', '7 e'] 305 let expected = ['1 a', '', '3 c', '', '5 ', '6 d', '7 e']
306 306
307 10new 307 10new
328 328
329 bw! 329 bw!
330 " clean up 330 " clean up
331 set formatprg= 331 set formatprg=
332 setlocal formatprg= 332 setlocal formatprg=
333 call delete('Xsed_format.sh')
334 endfunc 333 endfunc
335 334
336 func Test_normal07_internalfmt() 335 func Test_normal07_internalfmt()
337 " basic test for internal formmatter to textwidth of 12 336 " basic test for internal formmatter to textwidth of 12
338 let list=range(1,11) 337 let list=range(1,11)
700 " should fail 699 " should fail
701 let cleanup =<< trim END 700 let cleanup =<< trim END
702 call writefile([execute('messages')], 'Xtest.out') 701 call writefile([execute('messages')], 'Xtest.out')
703 qall 702 qall
704 END 703 END
705 call writefile(cleanup, 'Xverify.vim') 704 call writefile(cleanup, 'Xverify.vim', 'D')
706 call RunVim([], [], "-c \"set opfunc=s:abc\" -S Xverify.vim") 705 call RunVim([], [], "-c \"set opfunc=s:abc\" -S Xverify.vim")
707 call assert_match('E81: Using <SID> not in a', readfile('Xtest.out')[0]) 706 call assert_match('E81: Using <SID> not in a', readfile('Xtest.out')[0])
708 call delete('Xtest.out') 707 call delete('Xtest.out')
709 call delete('Xverify.vim')
710 708
711 " cleanup 709 " cleanup
712 set opfunc& 710 set opfunc&
713 delfunc OpFunc1 711 delfunc OpFunc1
714 delfunc OpFunc2 712 delfunc OpFunc2
1290 diffsplit 1288 diffsplit
1291 norm os00( 1289 norm os00(
1292 call writefile(['done'], 'Xdone') 1290 call writefile(['done'], 'Xdone')
1293 qa! 1291 qa!
1294 END 1292 END
1295 call writefile(lines, 'Xscript') 1293 call writefile(lines, 'Xscript', 'D')
1296 call assert_equal(1, RunVim([], [], '--clean -X -Z -e -s -S Xscript')) 1294 call assert_equal(1, RunVim([], [], '--clean -X -Z -e -s -S Xscript'))
1297 call assert_equal(['done'], readfile('Xdone')) 1295 call assert_equal(['done'], readfile('Xdone'))
1298 1296
1299 call delete('Xscript')
1300 call delete('Xdone') 1297 call delete('Xdone')
1301 endfunc 1298 endfunc
1302 1299
1303 " Test for the 'sidescroll' option 1300 " Test for the 'sidescroll' option
1304 func Test_sidescroll_opt() 1301 func Test_sidescroll_opt()
1707 endfunc 1704 endfunc
1708 1705
1709 func Test_normal20_exmode() 1706 func Test_normal20_exmode()
1710 " Reading from redirected file doesn't work on MS-Windows 1707 " Reading from redirected file doesn't work on MS-Windows
1711 CheckNotMSWindows 1708 CheckNotMSWindows
1712 call writefile(['1a', 'foo', 'bar', '.', 'w! Xn20file2', 'q!'], 'Xn20script') 1709 call writefile(['1a', 'foo', 'bar', '.', 'w! Xn20file2', 'q!'], 'Xn20script', 'D')
1713 call writefile(['1', '2'], 'Xn20file') 1710 call writefile(['1', '2'], 'Xn20file', 'D')
1714 call system(GetVimCommand() .. ' -e -s < Xn20script Xn20file') 1711 call system(GetVimCommand() .. ' -e -s < Xn20script Xn20file')
1715 let a=readfile('Xn20file2') 1712 let a = readfile('Xn20file2')
1716 call assert_equal(['1', 'foo', 'bar', '2'], a) 1713 call assert_equal(['1', 'foo', 'bar', '2'], a)
1717 1714
1718 " clean up 1715 " clean up
1719 for file in ['Xn20file', 'Xn20file2', 'Xn20script'] 1716 call delete('Xn20file2')
1720 call delete(file)
1721 endfor
1722 bw! 1717 bw!
1723 endfunc 1718 endfunc
1724 1719
1725 func Test_normal21_nv_hat() 1720 func Test_normal21_nv_hat()
1726 1721
1756 1751
1757 func Test_normal22_zet() 1752 func Test_normal22_zet()
1758 " Test for ZZ 1753 " Test for ZZ
1759 " let shell = &shell 1754 " let shell = &shell
1760 " let &shell = 'sh' 1755 " let &shell = 'sh'
1761 call writefile(['1', '2'], 'Xn22file') 1756 call writefile(['1', '2'], 'Xn22file', 'D')
1762 let args = ' -N -i NONE --noplugins -X --not-a-term' 1757 let args = ' -N -i NONE --noplugins -X --not-a-term'
1763 call system(GetVimCommand() .. args .. ' -c "%d" -c ":norm! ZZ" Xn22file') 1758 call system(GetVimCommand() .. args .. ' -c "%d" -c ":norm! ZZ" Xn22file')
1764 let a = readfile('Xn22file') 1759 let a = readfile('Xn22file')
1765 call assert_equal([], a) 1760 call assert_equal([], a)
1766 " Test for ZQ 1761 " Test for ZQ
1771 1766
1772 " Unsupported Z command 1767 " Unsupported Z command
1773 call assert_beeps('normal! ZW') 1768 call assert_beeps('normal! ZW')
1774 1769
1775 " clean up 1770 " clean up
1776 for file in ['Xn22file']
1777 call delete(file)
1778 endfor
1779 " let &shell = shell 1771 " let &shell = shell
1780 endfunc 1772 endfunc
1781 1773
1782 func Test_normal23_K() 1774 func Test_normal23_K()
1783 " Test for K command 1775 " Test for K command
3139 3131
3140 func Test_normal51_FileChangedRO() 3132 func Test_normal51_FileChangedRO()
3141 CheckFeature autocmd 3133 CheckFeature autocmd
3142 " Don't sleep after the warning message. 3134 " Don't sleep after the warning message.
3143 call test_settime(1) 3135 call test_settime(1)
3144 call writefile(['foo'], 'Xreadonly.log') 3136 call writefile(['foo'], 'Xreadonly.log', 'D')
3145 new Xreadonly.log 3137 new Xreadonly.log
3146 setl ro 3138 setl ro
3147 au FileChangedRO <buffer> :call feedkeys("\<c-^>", 'tix') 3139 au FileChangedRO <buffer> :call feedkeys("\<c-^>", 'tix')
3148 call assert_fails(":norm! Af", 'E788:') 3140 call assert_fails(":norm! Af", 'E788:')
3149 call assert_equal(['foo'], getline(1,'$')) 3141 call assert_equal(['foo'], getline(1,'$'))
3150 call assert_equal('Xreadonly.log', bufname('')) 3142 call assert_equal('Xreadonly.log', bufname(''))
3151 3143
3152 " cleanup 3144 " cleanup
3153 call test_settime(0) 3145 call test_settime(0)
3154 bw! 3146 bw!
3155 call delete("Xreadonly.log")
3156 endfunc 3147 endfunc
3157 3148
3158 func Test_normal52_rl() 3149 func Test_normal52_rl()
3159 CheckFeature rightleft 3150 CheckFeature rightleft
3160 new 3151 new