blob: ef1bf1075bbb6f627497017639b667681ae787d0 [file] [log] [blame]
Bram Moolenaar53f16732016-09-07 20:46:39 +02001
2" This is a test if a URL is recognized by "gf", with the cursor before and
3" after the "://". Also test ":\\".
Bram Moolenaar2a79ed22017-05-24 09:51:39 +02004func Test_gf_url()
Bram Moolenaar53f16732016-09-07 20:46:39 +02005 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!
Bram Moolenaar2a79ed22017-05-24 09:51:39 +020033endfunc
34
35func Test_gF()
36 new
37 call setline(1, ['111', '222', '333', '444'])
38 w! Xfile
39 close
40 new
Bram Moolenaar712598f2017-05-24 10:42:37 +020041 set isfname-=:
42 call setline(1, ['one', 'Xfile:3', 'three'])
Bram Moolenaar2a79ed22017-05-24 09:51:39 +020043 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
Bram Moolenaar712598f2017-05-24 10:42:37 +020051 set isfname&
Bram Moolenaar2a79ed22017-05-24 09:51:39 +020052 call delete('Xfile')
53 call delete('Xfile2')
54 bwipe Xfile
55 bwipe Xfile2
56endfunc