comparison src/testdir/test_startup.vim @ 30769:ae10b91ac6b3 v9.0.0719

patch 9.0.0719: too many delete() calls in tests Commit: https://github.com/vim/vim/commit/56564964e6d0956c29687e8a10cb94fe42f5c097 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Oct 10 22:39:42 2022 +0100 patch 9.0.0719: 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 Mon, 10 Oct 2022 23:45:04 +0200
parents 072c61082148
children 574bf5c78a40
comparison
equal deleted inserted replaced
30768:97a37fa9b03c 30769:ae10b91ac6b3
41 echo g:sequence 41 echo g:sequence
42 redir END 42 redir END
43 quit 43 quit
44 [CODE] 44 [CODE]
45 45
46 call mkdir('Xhere/plugin', 'p') 46 call mkdir('Xhere/plugin', 'pR')
47 call writefile(['let g:sequence .= "here "'], 'Xhere/plugin/here.vim') 47 call writefile(['let g:sequence .= "here "'], 'Xhere/plugin/here.vim')
48 call mkdir('Xanother/plugin', 'p') 48 call mkdir('Xanother/plugin', 'pR')
49 call writefile(['let g:sequence .= "another "'], 'Xanother/plugin/another.vim') 49 call writefile(['let g:sequence .= "another "'], 'Xanother/plugin/another.vim')
50 call mkdir('Xhere/pack/foo/start/foobar/plugin', 'p') 50 call mkdir('Xhere/pack/foo/start/foobar/plugin', 'p')
51 call writefile(['let g:sequence .= "pack "'], 'Xhere/pack/foo/start/foobar/plugin/foo.vim') 51 call writefile(['let g:sequence .= "pack "'], 'Xhere/pack/foo/start/foobar/plugin/foo.vim')
52 52
53 call mkdir('Xafter/plugin', 'p') 53 call mkdir('Xafter/plugin', 'pR')
54 call writefile(['let g:sequence .= "after "'], 'Xafter/plugin/later.vim') 54 call writefile(['let g:sequence .= "after "'], 'Xafter/plugin/later.vim')
55 55
56 if RunVim(before, after, '') 56 if RunVim(before, after, '')
57 57
58 let lines = readfile('Xtestout') 58 let lines = readfile('Xtestout')
70 70
71 call assert_equal('here another pack after', substitute(join(readfile('Xsequence', 1), ''), '\s\+$', '', '')) 71 call assert_equal('here another pack after', substitute(join(readfile('Xsequence', 1), ''), '\s\+$', '', ''))
72 72
73 call delete('Xtestout') 73 call delete('Xtestout')
74 call delete('Xsequence') 74 call delete('Xsequence')
75 call delete('Xhere', 'rf')
76 call delete('Xanother', 'rf')
77 call delete('Xafter', 'rf')
78 endfunc 75 endfunc
79 76
80 func Test_pack_in_rtp_when_plugins_run() 77 func Test_pack_in_rtp_when_plugins_run()
81 CheckFeature packages 78 CheckFeature packages
82 let before =<< trim [CODE] 79 let before =<< trim [CODE]
90 [CODE] 87 [CODE]
91 88
92 let after = [ 89 let after = [
93 \ 'quit', 90 \ 'quit',
94 \ ] 91 \ ]
95 call mkdir('Xhere/plugin', 'p') 92 call mkdir('Xhere/plugin', 'pR')
96 call writefile(['redir! > Xtestout', 'silent set runtimepath?', 'silent! call foo#Trigger()', 'redir END'], 'Xhere/plugin/here.vim') 93 call writefile(['redir! > Xtestout', 'silent set runtimepath?', 'silent! call foo#Trigger()', 'redir END'], 'Xhere/plugin/here.vim')
97 call mkdir('Xhere/pack/foo/start/foobar/autoload', 'p') 94 call mkdir('Xhere/pack/foo/start/foobar/autoload', 'p')
98 call writefile(['function! foo#Trigger()', 'echo "autoloaded foo"', 'endfunction'], 'Xhere/pack/foo/start/foobar/autoload/foo.vim') 95 call writefile(['function! foo#Trigger()', 'echo "autoloaded foo"', 'endfunction'], 'Xhere/pack/foo/start/foobar/autoload/foo.vim')
99 96
100 if RunVim(before, after, '') 97 if RunVim(before, after, '')
103 call assert_match('Xhere[/\\]pack[/\\]foo[/\\]start[/\\]foobar', get(lines, 0)) 100 call assert_match('Xhere[/\\]pack[/\\]foo[/\\]start[/\\]foobar', get(lines, 0))
104 call assert_match('autoloaded foo', get(lines, 1)) 101 call assert_match('autoloaded foo', get(lines, 1))
105 endif 102 endif
106 103
107 call delete('Xtestout') 104 call delete('Xtestout')
108 call delete('Xhere', 'rf')
109 endfunc 105 endfunc
110 106
111 func Test_help_arg() 107 func Test_help_arg()
112 " This does not work with a GUI-only binary, such as on MS-Windows. 108 " This does not work with a GUI-only binary, such as on MS-Windows.
113 CheckAnyOf Unix NotGui 109 CheckAnyOf Unix NotGui
226 call assert_equal(wh1, wh2) 222 call assert_equal(wh1, wh2)
227 call assert_equal(string(wh1 + 2), ln) 223 call assert_equal(string(wh1 + 2), ln)
228 call assert_equal('foo', bn1) 224 call assert_equal('foo', bn1)
229 call assert_equal('bar', bn2) 225 call assert_equal('bar', bn2)
230 endif 226 endif
231
232 call delete('Xtestout') 227 call delete('Xtestout')
233 endfunc 228 endfunc
234 229
235 " Test the -p[N] argument to open N tabpages. 230 " Test the -p[N] argument to open N tabpages.
236 func Test_p_arg() 231 func Test_p_arg()
301 main() { 296 main() {
302 functionCall(arg; arg, arg); 297 functionCall(arg; arg, arg);
303 return 666 298 return 666
304 } 299 }
305 END 300 END
306 call writefile(lines, 'Xbadfile.c') 301 call writefile(lines, 'Xbadfile.c', 'D')
307 302
308 let after =<< trim [CODE] 303 let after =<< trim [CODE]
309 call writefile([&errorfile, string(getpos("."))], "XtestoutQarg") 304 call writefile([&errorfile, string(getpos("."))], "XtestoutQarg")
310 copen 305 copen
311 w >> XtestoutQarg 306 w >> XtestoutQarg
312 qall 307 qall
313 [CODE] 308 [CODE]
314 309
315 " Test with default argument '-q'. 310 " Test with default argument '-q'.
316 call assert_equal('errors.err', &errorfile) 311 call assert_equal('errors.err', &errorfile)
317 call writefile(["Xbadfile.c:4:12: error: expected ';' before '}' token"], 'errors.err') 312 call writefile(["Xbadfile.c:4:12: error: expected ';' before '}' token"], 'errors.err', 'D')
318 if RunVim([], after, '-q') 313 if RunVim([], after, '-q')
319 let lines = readfile('XtestoutQarg') 314 let lines = readfile('XtestoutQarg')
320 call assert_equal(['errors.err', 315 call assert_equal(['errors.err',
321 \ '[0, 4, 12, 0]', 316 \ '[0, 4, 12, 0]',
322 \ "Xbadfile.c|4 col 12| error: expected ';' before '}' token"], 317 \ "Xbadfile.c|4 col 12| error: expected ';' before '}' token"],
323 \ lines) 318 \ lines)
324 endif 319 endif
325 call delete('XtestoutQarg') 320 call delete('XtestoutQarg')
326 call delete('errors.err')
327 321
328 " Test with explicit argument '-q XerrorsQarg' (with space). 322 " Test with explicit argument '-q XerrorsQarg' (with space).
329 call writefile(["Xbadfile.c:4:12: error: expected ';' before '}' token"], 'XerrorsQarg') 323 call writefile(["Xbadfile.c:4:12: error: expected ';' before '}' token"], 'XerrorsQarg', 'D')
330 if RunVim([], after, '-q XerrorsQarg') 324 if RunVim([], after, '-q XerrorsQarg')
331 let lines = readfile('XtestoutQarg') 325 let lines = readfile('XtestoutQarg')
332 call assert_equal(['XerrorsQarg', 326 call assert_equal(['XerrorsQarg',
333 \ '[0, 4, 12, 0]', 327 \ '[0, 4, 12, 0]',
334 \ "Xbadfile.c|4 col 12| error: expected ';' before '}' token"], 328 \ "Xbadfile.c|4 col 12| error: expected ';' before '}' token"],
347 341
348 " Test with a non-existing error file (exits with value 3) 342 " Test with a non-existing error file (exits with value 3)
349 let out = system(GetVimCommand() .. ' -q xyz.err') 343 let out = system(GetVimCommand() .. ' -q xyz.err')
350 call assert_equal(3, v:shell_error) 344 call assert_equal(3, v:shell_error)
351 345
352 call delete('Xbadfile.c')
353 call delete('XtestoutQarg') 346 call delete('XtestoutQarg')
354 call delete('XerrorsQarg')
355 endfunc 347 endfunc
356 348
357 " Test the -V[N]{filename} argument to set the 'verbose' option to N 349 " Test the -V[N]{filename} argument to set the 'verbose' option to N
358 " and set 'verbosefile' to filename. 350 " and set 'verbosefile' to filename.
359 func Test_V_file_arg() 351 func Test_V_file_arg()
398 endfunc 390 endfunc
399 391
400 " Test the -A, -F and -H arguments (Arabic, Farsi and Hebrew modes). 392 " Test the -A, -F and -H arguments (Arabic, Farsi and Hebrew modes).
401 func Test_A_F_H_arg() 393 func Test_A_F_H_arg()
402 let after =<< trim [CODE] 394 let after =<< trim [CODE]
403 call writefile([&rightleft, &arabic, &fkmap, &hkmap], "Xtestout") 395 call writefile([&rightleft, &arabic, &fkmap, &hkmap], "Xtestout", 'D')
404 qall 396 qall
405 [CODE] 397 [CODE]
406 398
407 " Use silent Ex mode to avoid the hit-Enter prompt for the warning that 399 " Use silent Ex mode to avoid the hit-Enter prompt for the warning that
408 " 'encoding' is not utf-8. 400 " 'encoding' is not utf-8.
418 410
419 if has('rightleft') && RunVim([], after, '-H') 411 if has('rightleft') && RunVim([], after, '-H')
420 let lines = readfile('Xtestout') 412 let lines = readfile('Xtestout')
421 call assert_equal(['1', '0', '0', '1'], lines) 413 call assert_equal(['1', '0', '0', '1'], lines)
422 endif 414 endif
423
424 call delete('Xtestout')
425 endfunc 415 endfunc
426 416
427 " Test the --echo-wid argument (for GTK GUI only). 417 " Test the --echo-wid argument (for GTK GUI only).
428 func Test_echo_wid() 418 func Test_echo_wid()
429 CheckCanRunGui 419 CheckCanRunGui
797 let $TERM = save_term 787 let $TERM = save_term
798 endfunc 788 endfunc
799 789
800 func Test_zzz_startinsert() 790 func Test_zzz_startinsert()
801 " Test :startinsert 791 " Test :startinsert
802 call writefile(['123456'], 'Xtestout') 792 call writefile(['123456'], 'Xtestout', 'D')
803 let after =<< trim [CODE] 793 let after =<< trim [CODE]
804 :startinsert 794 :startinsert
805 call feedkeys("foobar\<c-o>:wq\<cr>","t") 795 call feedkeys("foobar\<c-o>:wq\<cr>","t")
806 [CODE] 796 [CODE]
807 797
818 808
819 if RunVim([], after, 'Xtestout') 809 if RunVim([], after, 'Xtestout')
820 let lines = readfile('Xtestout') 810 let lines = readfile('Xtestout')
821 call assert_equal(['123456foobar'], lines) 811 call assert_equal(['123456foobar'], lines)
822 endif 812 endif
823 call delete('Xtestout')
824 endfunc 813 endfunc
825 814
826 func Test_issue_3969() 815 func Test_issue_3969()
827 " Can't catch the output of gvim. 816 " Can't catch the output of gvim.
828 CheckNotGui 817 CheckNotGui
896 885
897 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", 886 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
898 \ "first\tXfile1\t/^ \\zsfirst$/", 887 \ "first\tXfile1\t/^ \\zsfirst$/",
899 \ "second\tXfile1\t/^ \\zssecond$/", 888 \ "second\tXfile1\t/^ \\zssecond$/",
900 \ "third\tXfile1\t/^ \\zsthird$/"], 889 \ "third\tXfile1\t/^ \\zsthird$/"],
901 \ 'Xtags') 890 \ 'Xtags', 'D')
902 call writefile([' first', ' second', ' third'], 'Xfile1') 891 call writefile([' first', ' second', ' third'], 'Xfile1', 'D')
903 892
904 for t_arg in ['-t second', '-tsecond'] 893 for t_arg in ['-t second', '-tsecond']
905 if RunVim(before, after, t_arg) 894 if RunVim(before, after, t_arg)
906 call assert_equal(['Xfile1:L2C5'], readfile('Xtestout'), t_arg) 895 call assert_equal(['Xfile1:L2C5'], readfile('Xtestout'), t_arg)
907 call delete('Xtestout') 896 call delete('Xtestout')
908 endif 897 endif
909 endfor 898 endfor
910
911 call delete('Xtags')
912 call delete('Xfile1')
913 endfunc 899 endfunc
914 900
915 " Test the '-T' argument which sets the 'term' option. 901 " Test the '-T' argument which sets the 'term' option.
916 func Test_T_arg() 902 func Test_T_arg()
917 CheckNotGui 903 CheckNotGui
1004 CheckRunVimInTerminal 990 CheckRunVimInTerminal
1005 let after =<< trim [CODE] 991 let after =<< trim [CODE]
1006 call assert_match('^E282:', v:errmsg) 992 call assert_match('^E282:', v:errmsg)
1007 call writefile(v:errors, 'Xtestout') 993 call writefile(v:errors, 'Xtestout')
1008 [CODE] 994 [CODE]
1009 call writefile(after, 'Xafter') 995 call writefile(after, 'Xafter', 'D')
1010 996
1011 let cmd = GetVimCommandCleanTerm() . ' -u Xvimrc_missing -S Xafter' 997 let cmd = GetVimCommandCleanTerm() . ' -u Xvimrc_missing -S Xafter'
1012 let buf = term_start(cmd, {'term_rows' : 10}) 998 let buf = term_start(cmd, {'term_rows' : 10})
1013 call WaitForAssert({-> assert_equal("running", term_getstatus(buf))}) 999 call WaitForAssert({-> assert_equal("running", term_getstatus(buf))})
1014 call TermWait(buf) 1000 call TermWait(buf)
1015 call term_sendkeys(buf, "\n:") 1001 call term_sendkeys(buf, "\n:")
1016 call TermWait(buf) 1002 call TermWait(buf)
1017 call WaitForAssert({-> assert_match(':', term_getline(buf, 10))}) 1003 call WaitForAssert({-> assert_match(':', term_getline(buf, 10))})
1018 call StopVimInTerminal(buf) 1004 call StopVimInTerminal(buf)
1019 call assert_equal([], readfile('Xtestout')) 1005 call assert_equal([], readfile('Xtestout'))
1020 call delete('Xafter') 1006
1021 call delete('Xtestout') 1007 call delete('Xtestout')
1022 endfunc 1008 endfunc
1023 1009
1024 " Test for using the $VIMINIT environment variable 1010 " Test for using the $VIMINIT environment variable
1025 func Test_VIMINIT() 1011 func Test_VIMINIT()
1027 call assert_equal(1, exists('viminit_found')) 1013 call assert_equal(1, exists('viminit_found'))
1028 call assert_equal('yes', viminit_found) 1014 call assert_equal('yes', viminit_found)
1029 call writefile(v:errors, 'Xtestout') 1015 call writefile(v:errors, 'Xtestout')
1030 qall 1016 qall
1031 [CODE] 1017 [CODE]
1032 call writefile(after, 'Xafter') 1018 call writefile(after, 'Xafter', 'D')
1033 let cmd = GetVimProg() . ' --not-a-term -S Xafter --cmd "set enc=utf8"' 1019 let cmd = GetVimProg() . ' --not-a-term -S Xafter --cmd "set enc=utf8"'
1034 call setenv('VIMINIT', 'let viminit_found="yes"') 1020 call setenv('VIMINIT', 'let viminit_found="yes"')
1035 exe "silent !" . cmd 1021 exe "silent !" . cmd
1036 call assert_equal([], readfile('Xtestout')) 1022 call assert_equal([], readfile('Xtestout'))
1023
1037 call delete('Xtestout') 1024 call delete('Xtestout')
1038 call delete('Xafter')
1039 endfunc 1025 endfunc
1040 1026
1041 " Test for using the $EXINIT environment variable 1027 " Test for using the $EXINIT environment variable
1042 func Test_EXINIT() 1028 func Test_EXINIT()
1043 let after =<< trim [CODE] 1029 let after =<< trim [CODE]
1044 call assert_equal(1, exists('exinit_found')) 1030 call assert_equal(1, exists('exinit_found'))
1045 call assert_equal('yes', exinit_found) 1031 call assert_equal('yes', exinit_found)
1046 call writefile(v:errors, 'Xtestout') 1032 call writefile(v:errors, 'Xtestout')
1047 qall 1033 qall
1048 [CODE] 1034 [CODE]
1049 call writefile(after, 'Xafter') 1035 call writefile(after, 'Xafter', 'D')
1050 let cmd = GetVimProg() . ' --not-a-term -S Xafter --cmd "set enc=utf8"' 1036 let cmd = GetVimProg() . ' --not-a-term -S Xafter --cmd "set enc=utf8"'
1051 call setenv('EXINIT', 'let exinit_found="yes"') 1037 call setenv('EXINIT', 'let exinit_found="yes"')
1052 exe "silent !" . cmd 1038 exe "silent !" . cmd
1053 call assert_equal([], readfile('Xtestout')) 1039 call assert_equal([], readfile('Xtestout'))
1040
1054 call delete('Xtestout') 1041 call delete('Xtestout')
1055 call delete('Xafter')
1056 endfunc 1042 endfunc
1057 1043
1058 " Test for using the 'exrc' option 1044 " Test for using the 'exrc' option
1059 func Test_exrc() 1045 func Test_exrc()
1060 let after =<< trim [CODE] 1046 let after =<< trim [CODE]
1062 call assert_equal(1, &secure) 1048 call assert_equal(1, &secure)
1063 call assert_equal(37, exrc_found) 1049 call assert_equal(37, exrc_found)
1064 call writefile(v:errors, 'Xtestout') 1050 call writefile(v:errors, 'Xtestout')
1065 qall 1051 qall
1066 [CODE] 1052 [CODE]
1067 call mkdir('Xrcdir') 1053 call mkdir('Xrcdir', 'R')
1068 call writefile(['let exrc_found=37'], 'Xrcdir/.exrc') 1054 call writefile(['let exrc_found=37'], 'Xrcdir/.exrc')
1069 call writefile(after, 'Xrcdir/Xafter') 1055 call writefile(after, 'Xrcdir/Xafter')
1070 let cmd = GetVimProg() . ' --not-a-term -S Xafter --cmd "cd Xrcdir" --cmd "set enc=utf8 exrc secure"' 1056 let cmd = GetVimProg() . ' --not-a-term -S Xafter --cmd "cd Xrcdir" --cmd "set enc=utf8 exrc secure"'
1071 exe "silent !" . cmd 1057 exe "silent !" . cmd
1072 call assert_equal([], readfile('Xrcdir/Xtestout')) 1058 call assert_equal([], readfile('Xrcdir/Xtestout'))
1073 call delete('Xrcdir', 'rf')
1074 endfunc 1059 endfunc
1075 1060
1076 " Test for starting Vim with a non-terminal as input/output 1061 " Test for starting Vim with a non-terminal as input/output
1077 func Test_io_not_a_terminal() 1062 func Test_io_not_a_terminal()
1078 " Can't catch the output of gvim. 1063 " Can't catch the output of gvim.
1136 " Test for the "-w scriptout" argument 1121 " Test for the "-w scriptout" argument
1137 func Test_w_arg() 1122 func Test_w_arg()
1138 " Can't catch the output of gvim. 1123 " Can't catch the output of gvim.
1139 CheckNotGui 1124 CheckNotGui
1140 1125
1141 call writefile(["iVim Editor\<Esc>:q!\<CR>"], 'Xscriptin', 'b') 1126 call writefile(["iVim Editor\<Esc>:q!\<CR>"], 'Xscriptin', 'bD')
1142 if RunVim([], [], '-s Xscriptin -w Xscriptout') 1127 if RunVim([], [], '-s Xscriptin -w Xscriptout')
1143 call assert_equal(["iVim Editor\e:q!\r"], readfile('Xscriptout')) 1128 call assert_equal(["iVim Editor\e:q!\r"], readfile('Xscriptout'))
1144 call delete('Xscriptout') 1129 call delete('Xscriptout')
1145 endif 1130 endif
1146 call delete('Xscriptin') 1131 call delete('Xscriptin')
1160 if RunVim([], [], '-s Xscriptin ' .. w_arg) 1145 if RunVim([], [], '-s Xscriptin ' .. w_arg)
1161 call assert_equal(["window 17"], readfile('Xresult'), w_arg) 1146 call assert_equal(["window 17"], readfile('Xresult'), w_arg)
1162 call delete('Xresult') 1147 call delete('Xresult')
1163 endif 1148 endif
1164 endfor 1149 endfor
1165 call delete('Xscriptin')
1166 endfunc 1150 endfunc
1167 1151
1168 " Test for the "-s scriptin" argument 1152 " Test for the "-s scriptin" argument
1169 func Test_s_arg() 1153 func Test_s_arg()
1170 " Can't catch the output of gvim. 1154 " Can't catch the output of gvim.
1172 CheckEnglish 1156 CheckEnglish
1173 " Test for failing to open the script input file. 1157 " Test for failing to open the script input file.
1174 let m = system(GetVimCommand() .. " -s abcxyz") 1158 let m = system(GetVimCommand() .. " -s abcxyz")
1175 call assert_equal("Cannot open for reading: \"abcxyz\"\n", m) 1159 call assert_equal("Cannot open for reading: \"abcxyz\"\n", m)
1176 1160
1177 call writefile([], 'Xinput') 1161 call writefile([], 'Xinput', 'D')
1178 let m = system(GetVimCommand() .. " -s Xinput -s Xinput") 1162 let m = system(GetVimCommand() .. " -s Xinput -s Xinput")
1179 call assert_equal("Attempt to open script file again: \"-s Xinput\"\n", m) 1163 call assert_equal("Attempt to open script file again: \"-s Xinput\"\n", m)
1180 call delete('Xinput')
1181 endfunc 1164 endfunc
1182 1165
1183 " Test for the "-n" (no swap file) argument 1166 " Test for the "-n" (no swap file) argument
1184 func Test_n_arg() 1167 func Test_n_arg()
1185 let after =<< trim [CODE] 1168 let after =<< trim [CODE]
1250 1233
1251 " Test starting vim with various names: vim, ex, view, evim, etc. 1234 " Test starting vim with various names: vim, ex, view, evim, etc.
1252 func Test_progname() 1235 func Test_progname()
1253 CheckUnix 1236 CheckUnix
1254 1237
1255 call mkdir('Xprogname', 'p') 1238 call mkdir('Xprogname', 'pD')
1256 call writefile(['silent !date', 1239 call writefile(['silent !date',
1257 \ 'call writefile([mode(1), ' 1240 \ 'call writefile([mode(1), '
1258 \ .. '&insertmode, &diff, &readonly, &updatecount, ' 1241 \ .. '&insertmode, &diff, &readonly, &updatecount, '
1259 \ .. 'join(split(execute("message"), "\n")[1:])], "Xprogname_out")', 1242 \ .. 'join(split(execute("message"), "\n")[1:])], "Xprogname_out")',
1260 \ 'qall'], 'Xprogname_after') 1243 \ 'qall'], 'Xprogname_after')
1322 call delete('Xprogname/' .. progname) 1305 call delete('Xprogname/' .. progname)
1323 call delete('Xprogname_out') 1306 call delete('Xprogname_out')
1324 endfor 1307 endfor
1325 1308
1326 call delete('Xprogname_after') 1309 call delete('Xprogname_after')
1327 call delete('Xprogname', 'd')
1328 endfunc 1310 endfunc
1329 1311
1330 " Test for doing a write from .vimrc 1312 " Test for doing a write from .vimrc
1331 func Test_write_in_vimrc() 1313 func Test_write_in_vimrc()
1332 call writefile(['silent! write'], 'Xvimrc') 1314 call writefile(['silent! write'], 'Xvimrc', 'D')
1333 let after =<< trim [CODE] 1315 let after =<< trim [CODE]
1334 call assert_match('E32: ', v:errmsg) 1316 call assert_match('E32: ', v:errmsg)
1335 call writefile(v:errors, 'Xtestout') 1317 call writefile(v:errors, 'Xtestout')
1336 qall 1318 qall
1337 [CODE] 1319 [CODE]
1338 if RunVim([], after, '-u Xvimrc') 1320 if RunVim([], after, '-u Xvimrc')
1339 call assert_equal([], readfile('Xtestout')) 1321 call assert_equal([], readfile('Xtestout'))
1340 call delete('Xtestout') 1322 call delete('Xtestout')
1341 endif 1323 endif
1342 call delete('Xvimrc')
1343 endfunc 1324 endfunc
1344 1325
1345 func Test_echo_true_in_cmd() 1326 func Test_echo_true_in_cmd()
1346 CheckNotGui 1327 CheckNotGui
1347 1328
1348 let lines =<< trim END 1329 let lines =<< trim END
1349 echo v:true 1330 echo v:true
1350 call writefile(['done'], 'Xresult') 1331 call writefile(['done'], 'Xresult')
1351 quit 1332 quit
1352 END 1333 END
1353 call writefile(lines, 'Xscript') 1334 call writefile(lines, 'Xscript', 'D')
1354 if RunVim([], [], '--cmd "source Xscript"') 1335 if RunVim([], [], '--cmd "source Xscript"')
1355 call assert_equal(['done'], readfile('Xresult')) 1336 call assert_equal(['done'], readfile('Xresult'))
1356 endif 1337 endif
1357 call delete('Xscript') 1338
1358 call delete('Xresult') 1339 call delete('Xresult')
1359 endfunc 1340 endfunc
1360 1341
1361 func Test_rename_buffer_on_startup() 1342 func Test_rename_buffer_on_startup()
1362 CheckUnix 1343 CheckUnix
1363 1344
1364 let lines =<< trim END 1345 let lines =<< trim END
1365 call writefile(['done'], 'Xresult') 1346 call writefile(['done'], 'Xresult')
1366 qa! 1347 qa!
1367 END 1348 END
1368 call writefile(lines, 'Xscript') 1349 call writefile(lines, 'Xscript', 'D')
1369 if RunVim([], [], "--clean -e -s --cmd 'file x|new|file x' --cmd 'so Xscript'") 1350 if RunVim([], [], "--clean -e -s --cmd 'file x|new|file x' --cmd 'so Xscript'")
1370 call assert_equal(['done'], readfile('Xresult')) 1351 call assert_equal(['done'], readfile('Xresult'))
1371 endif 1352 endif
1372 call delete('Xscript') 1353
1373 call delete('Xresult') 1354 call delete('Xresult')
1374 endfunc 1355 endfunc
1375 1356
1376 1357
1377 " vim: shiftwidth=2 sts=2 expandtab 1358 " vim: shiftwidth=2 sts=2 expandtab