xref: /vim-8.2.3635/src/testdir/test_gf.vim (revision 8ee2d36e)
1
2" This is a test if a URL is recognized by "gf", with the cursor before and
3" after the "://".  Also test ":\\".
4func Test_gf_url()
5  enew!
6  call append(0, [
7      \ "first test for URL://machine.name/tmp/vimtest2a and other text",
8      \ "second test for URL://machine.name/tmp/vimtest2b. And other text",
9      \ "third test for URL:\\\\machine.name\\vimtest2c and other text",
10      \ "fourth test for URL:\\\\machine.name\\tmp\\vimtest2d, and other text"
11      \ ])
12  call cursor(1,1)
13  call search("^first")
14  call search("tmp")
15  call assert_equal("URL://machine.name/tmp/vimtest2a", expand("<cfile>"))
16  call search("^second")
17  call search("URL")
18  call assert_equal("URL://machine.name/tmp/vimtest2b", expand("<cfile>"))
19  if has("ebcdic")
20      set isf=@,240-249,/,.,-,_,+,,,$,:,~,\
21  else
22      set isf=@,48-57,/,.,-,_,+,,,$,:,~,\
23  endif
24  call search("^third")
25  call search("name")
26  call assert_equal("URL:\\\\machine.name\\vimtest2c", expand("<cfile>"))
27  call search("^fourth")
28  call search("URL")
29  call assert_equal("URL:\\\\machine.name\\tmp\\vimtest2d", expand("<cfile>"))
30
31  set isf&vim
32  enew!
33endfunc
34
35func Test_gF()
36  new
37  call setline(1, ['111', '222', '333', '444'])
38  w! Xfile
39  close
40  new
41  set isfname-=:
42  call setline(1, ['one', 'Xfile:3', 'three'])
43  2
44  call assert_fails('normal gF', 'E37:')
45  call assert_equal(2, getcurpos()[1])
46  w! Xfile2
47  normal gF
48  call assert_equal('Xfile', bufname('%'))
49  call assert_equal(3, getcurpos()[1])
50
51  set isfname&
52  call delete('Xfile')
53  call delete('Xfile2')
54  bwipe Xfile
55  bwipe Xfile2
56endfunc
57