comparison src/testdir/test_gf.vim @ 20978:2c3e7a6bd6c6 v8.2.1040

patch 8.2.1040: not enough testing for movement commands Commit: https://github.com/vim/vim/commit/bdd2c290d3cda69e0046c42f0c651f60bc510a16 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jun 22 21:34:30 2020 +0200 patch 8.2.1040: not enough testing for movement commands Problem: Not enough testing for movement commands. Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/6313)
author Bram Moolenaar <Bram@vim.org>
date Mon, 22 Jun 2020 21:45:03 +0200
parents 252d2bb90394
children 6c634e63989c
comparison
equal deleted inserted replaced
20977:6953733825a7 20978:2c3e7a6bd6c6
1 " Test for the gf and gF (goto file) commands
1 2
2 " This is a test if a URL is recognized by "gf", with the cursor before and 3 " This is a test if a URL is recognized by "gf", with the cursor before and
3 " after the "://". Also test ":\\". 4 " after the "://". Also test ":\\".
4 func Test_gf_url() 5 func Test_gf_url()
5 enew! 6 enew!
35 call assert_equal("URL://machine.name/tmp?q=vim&opt=yes", expand("<cfile>")) 36 call assert_equal("URL://machine.name/tmp?q=vim&opt=yes", expand("<cfile>"))
36 37
37 call search("^sixth") 38 call search("^sixth")
38 call search("URL") 39 call search("URL")
39 call assert_equal("URL://machine.name:1234?q=vim", expand("<cfile>")) 40 call assert_equal("URL://machine.name:1234?q=vim", expand("<cfile>"))
41
42 %d
43 call setline(1, "demo://remote_file")
44 wincmd f
45 call assert_equal('demo://remote_file', @%)
46 call assert_equal(2, winnr('$'))
47 close!
40 48
41 set isf&vim 49 set isf&vim
42 enew! 50 enew!
43 endfunc 51 endfunc
44 52
116 124
117 " Visually select Xtest_gf_visual and use gf to go to that file 125 " Visually select Xtest_gf_visual and use gf to go to that file
118 norm! ttvtXgf 126 norm! ttvtXgf
119 call assert_equal('Xtest_gf_visual', bufname('%')) 127 call assert_equal('Xtest_gf_visual', bufname('%'))
120 128
129 " if multiple lines are selected, then gf should fail
130 call setline(1, ["one", "two"])
131 normal VGgf
132 call assert_equal('Xtest_gf_visual', @%)
133
121 bwipe! 134 bwipe!
122 call delete('Xtest_gf_visual') 135 call delete('Xtest_gf_visual')
123 set hidden& 136 set hidden&
124 endfunc 137 endfunc
125 138
144 au! InsertCharPre 157 au! InsertCharPre
145 158
146 bwipe! 159 bwipe!
147 endfunc 160 endfunc
148 161
162 " If a file is not found by 'gf', then 'includeexpr' should be used to locate
163 " the file.
164 func Test_gf_includeexpr()
165 new
166 let g:Inc_fname = ''
167 func IncFunc()
168 let g:Inc_fname = v:fname
169 return v:fname
170 endfunc
171 setlocal includeexpr=IncFunc()
172 call setline(1, 'somefile.java')
173 call assert_fails('normal gf', 'E447:')
174 call assert_equal('somefile.java', g:Inc_fname)
175 close!
176 delfunc IncFunc
177 endfunc
178
149 " vim: shiftwidth=2 sts=2 expandtab 179 " vim: shiftwidth=2 sts=2 expandtab