blob: c099edae1cc4f58990143c3984f96ab1d8654914 [file] [log] [blame]
Bram Moolenaar58adb142016-01-16 21:50:51 +01001" Test for expanding file names
2
3func Test_with_directories()
4 call mkdir('Xdir1')
5 call mkdir('Xdir2')
6 call mkdir('Xdir3')
7 cd Xdir3
8 call mkdir('Xdir4')
9 cd ..
10
11 split Xdir1/file
12 call setline(1, ['a', 'b'])
13 w
14 w Xdir3/Xdir4/file
15 close
16
17 next Xdir?/*/file
18 call assert_equal('Xdir3/Xdir4/file', expand('%'))
Bram Moolenaarf60b7962016-01-16 22:47:23 +010019 if has('unix')
20 next! Xdir?/*/nofile
21 call assert_equal('Xdir?/*/nofile', expand('%'))
22 endif
Bram Moolenaar08b270a2016-01-17 18:34:19 +010023 " Edit another file, on MS-Windows the swap file would be in use and can't
24 " be deleted.
25 edit foo
Bram Moolenaar58adb142016-01-16 21:50:51 +010026
Bram Moolenaar08b270a2016-01-17 18:34:19 +010027 call assert_equal(0, delete('Xdir1', 'rf'))
28 call assert_equal(0, delete('Xdir2', 'rf'))
29 call assert_equal(0, delete('Xdir3', 'rf'))
Bram Moolenaar58adb142016-01-16 21:50:51 +010030endfunc
31
32func Test_with_tilde()
33 let dir = getcwd()
34 call mkdir('Xdir ~ dir')
35 call assert_true(isdirectory('Xdir ~ dir'))
36 cd Xdir\ ~\ dir
37 call assert_true(getcwd() =~ 'Xdir \~ dir')
38 exe 'cd ' . fnameescape(dir)
39 call delete('Xdir ~ dir', 'd')
40 call assert_false(isdirectory('Xdir ~ dir'))
41endfunc