blob: c3523796972da6a7d8f2cf279fef236cd55c4d8a [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",
Bram Moolenaar9e3dfc62017-12-25 14:29:18 +010010 \ "fourth test for URL:\\\\machine.name\\tmp\\vimtest2d, and other text",
11 \ "fifth test for URL://machine.name/tmp?q=vim&opt=yes and other text",
Bram Moolenaar53f16732016-09-07 20:46:39 +020012 \ ])
13 call cursor(1,1)
14 call search("^first")
15 call search("tmp")
16 call assert_equal("URL://machine.name/tmp/vimtest2a", expand("<cfile>"))
17 call search("^second")
18 call search("URL")
19 call assert_equal("URL://machine.name/tmp/vimtest2b", expand("<cfile>"))
20 if has("ebcdic")
21 set isf=@,240-249,/,.,-,_,+,,,$,:,~,\
22 else
23 set isf=@,48-57,/,.,-,_,+,,,$,:,~,\
24 endif
25 call search("^third")
26 call search("name")
27 call assert_equal("URL:\\\\machine.name\\vimtest2c", expand("<cfile>"))
28 call search("^fourth")
29 call search("URL")
30 call assert_equal("URL:\\\\machine.name\\tmp\\vimtest2d", expand("<cfile>"))
31
Bram Moolenaar9e3dfc62017-12-25 14:29:18 +010032 call search("^fifth")
33 call search("URL")
34 call assert_equal("URL://machine.name/tmp?q=vim&opt=yes", expand("<cfile>"))
35
Bram Moolenaar53f16732016-09-07 20:46:39 +020036 set isf&vim
37 enew!
Bram Moolenaar2a79ed22017-05-24 09:51:39 +020038endfunc
39
40func Test_gF()
41 new
42 call setline(1, ['111', '222', '333', '444'])
43 w! Xfile
44 close
45 new
Bram Moolenaar712598f2017-05-24 10:42:37 +020046 set isfname-=:
47 call setline(1, ['one', 'Xfile:3', 'three'])
Bram Moolenaar2a79ed22017-05-24 09:51:39 +020048 2
49 call assert_fails('normal gF', 'E37:')
50 call assert_equal(2, getcurpos()[1])
51 w! Xfile2
52 normal gF
53 call assert_equal('Xfile', bufname('%'))
54 call assert_equal(3, getcurpos()[1])
55
Bram Moolenaar712598f2017-05-24 10:42:37 +020056 set isfname&
Bram Moolenaar2a79ed22017-05-24 09:51:39 +020057 call delete('Xfile')
58 call delete('Xfile2')
59 bwipe Xfile
60 bwipe Xfile2
61endfunc