comparison src/testdir/test_netbeans.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 ac7ad168caed
children 8492bbc9f533
comparison
equal deleted inserted replaced
30581:2e1ec75a7766 30582:72245f9c9405
39 " these messages will break the assert for the output. 39 " these messages will break the assert for the output.
40 return filter(l, 'v:val !~ "^0:geometry="') 40 return filter(l, 'v:val !~ "^0:geometry="')
41 endfunc 41 endfunc
42 42
43 func Nb_basic(port) 43 func Nb_basic(port)
44 call delete("Xnetbeans") 44 call writefile([], "Xnetbeans", 'D')
45 call writefile([], "Xnetbeans")
46 45
47 " Last line number in the Xnetbeans file. Used to verify the result of the 46 " Last line number in the Xnetbeans file. Used to verify the result of the
48 " communication with the netbeans server 47 " communication with the netbeans server
49 let g:last = 0 48 let g:last = 0
50 49
77 hide 76 hide
78 77
79 sleep 1m 78 sleep 1m
80 79
81 " getCursor test 80 " getCursor test
82 call writefile(['foo bar', 'foo bar', 'foo bar'], 'Xfile1') 81 call writefile(['foo bar', 'foo bar', 'foo bar'], 'Xfile1', 'D')
83 split Xfile1 82 split Xfile1
84 call cursor(3, 4) 83 call cursor(3, 4)
85 sleep 10m 84 sleep 10m
86 call appendbufline(cmdbufnr, '$', 'getCursor_Test') 85 call appendbufline(cmdbufnr, '$', 'getCursor_Test')
87 call WaitFor('len(ReadXnetbeans()) >= (g:last + 5)') 86 call WaitFor('len(ReadXnetbeans()) >= (g:last + 5)')
270 let l = ReadXnetbeans() 269 let l = ReadXnetbeans()
271 call assert_equal(['send: 0:getAnno/52 8', '52 0'], l[-2:]) 270 call assert_equal(['send: 0:getAnno/52 8', '52 0'], l[-2:])
272 let g:last += 4 271 let g:last += 4
273 272
274 " editFile test 273 " editFile test
275 call writefile(['foo bar1', 'foo bar2', 'foo bar3'], 'Xfile3') 274 call writefile(['foo bar1', 'foo bar2', 'foo bar3'], 'Xfile3', 'D')
276 call appendbufline(cmdbufnr, '$', 'editFile_Test') 275 call appendbufline(cmdbufnr, '$', 'editFile_Test')
277 call WaitFor('len(ReadXnetbeans()) >= (g:last + 4)') 276 call WaitFor('len(ReadXnetbeans()) >= (g:last + 4)')
278 let l = ReadXnetbeans() 277 let l = ReadXnetbeans()
279 call assert_equal('send: 2:editFile!53 "Xfile3"', l[-2]) 278 call assert_equal('send: 2:editFile!53 "Xfile3"', l[-2])
280 call assert_match('0:fileOpened=0 ".*/Xfile3" T F', l[-1]) 279 call assert_match('0:fileOpened=0 ".*/Xfile3" T F', l[-1])
836 835
837 " Remove all the signs 836 " Remove all the signs
838 call sign_unplace('*') 837 call sign_unplace('*')
839 call sign_undefine() 838 call sign_undefine()
840 839
841 call delete("Xnetbeans")
842 call delete('Xfile1')
843 call delete('Xfile3')
844 call delete('Xfile4') 840 call delete('Xfile4')
845 endfunc 841 endfunc
846 842
847 func Test_nb_basic() 843 func Test_nb_basic()
848 call ch_log('Test_nb_basic') 844 call ch_log('Test_nb_basic')
849 call s:run_server('Nb_basic') 845 call s:run_server('Nb_basic')
850 endfunc 846 endfunc
851 847
852 func Nb_file_auth(port) 848 func Nb_file_auth(port)
853 call delete("Xnetbeans") 849 call delete("Xnetbeans")
854 call writefile([], "Xnetbeans") 850 call writefile([], "Xnetbeans", 'D')
855 851
856 call assert_fails('nbstart =notexist', 'E660:') 852 call assert_fails('nbstart =notexist', 'E660:')
857 call writefile(['host=localhost', 'port=' . a:port, 'auth=bunny'], 'Xnbauth') 853 call writefile(['host=localhost', 'port=' . a:port, 'auth=bunny'], 'Xnbauth', 'D')
858 if has('unix') 854 if has('unix')
859 call setfperm('Xnbauth', "rw-r--r--") 855 call setfperm('Xnbauth', "rw-r--r--")
860 call assert_fails('nbstart =Xnbauth', 'E668:') 856 call assert_fails('nbstart =Xnbauth', 'E668:')
861 endif 857 endif
862 call setfperm('Xnbauth', "rw-------") 858 call setfperm('Xnbauth', "rw-------")
869 call assert_equal('AUTH bunny', lines[0]) 865 call assert_equal('AUTH bunny', lines[0])
870 call assert_equal('0:version=0 "2.5"', lines[1]) 866 call assert_equal('0:version=0 "2.5"', lines[1])
871 call assert_equal('0:startupDone=0', lines[2]) 867 call assert_equal('0:startupDone=0', lines[2])
872 868
873 call delete("Xnbauth") 869 call delete("Xnbauth")
874 call delete("Xnetbeans")
875 endfunc 870 endfunc
876 871
877 func Test_nb_file_auth() 872 func Test_nb_file_auth()
878 call ch_log('Test_nb_file_auth') 873 call ch_log('Test_nb_file_auth')
879 call s:run_server('Nb_file_auth') 874 call s:run_server('Nb_file_auth')
880 endfunc 875 endfunc
881 876
882 " Test for quitting Vim with an open netbeans connection 877 " Test for quitting Vim with an open netbeans connection
883 func Nb_quit_with_conn(port) 878 func Nb_quit_with_conn(port)
884 call delete("Xnetbeans") 879 call delete("Xnetbeans")
885 call writefile([], "Xnetbeans") 880 call writefile([], "Xnetbeans", 'D')
886 let after =<< trim END 881 let after =<< trim END
887 source shared.vim 882 source shared.vim
888 set cpo&vim 883 set cpo&vim
889 884
890 func ReadXnetbeans() 885 func ReadXnetbeans()
920 let l = ReadXnetbeans() 915 let l = ReadXnetbeans()
921 call assert_equal('1:unmodified=16', l[-3]) 916 call assert_equal('1:unmodified=16', l[-3])
922 call assert_equal('1:killed=16', l[-2]) 917 call assert_equal('1:killed=16', l[-2])
923 call assert_equal('0:disconnect=16', l[-1]) 918 call assert_equal('0:disconnect=16', l[-1])
924 endif 919 endif
925 call delete('Xnetbeans')
926 endfunc 920 endfunc
927 921
928 func Test_nb_quit_with_conn() 922 func Test_nb_quit_with_conn()
929 " Exiting Vim with a netbeans connection doesn't work properly on 923 " Exiting Vim with a netbeans connection doesn't work properly on
930 " MS-Windows. 924 " MS-Windows.