xref: /vim-8.2.3635/src/testdir/test_expand.vim (revision cf2d8dee)
1" 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('%'))
19  if has('unix')
20    next! Xdir?/*/nofile
21    call assert_equal('Xdir?/*/nofile', expand('%'))
22  endif
23  " Edit another file, on MS-Windows the swap file would be in use and can't
24  " be deleted.
25  edit foo
26
27  call assert_equal(0, delete('Xdir1', 'rf'))
28  call assert_equal(0, delete('Xdir2', 'rf'))
29  call assert_equal(0, delete('Xdir3', 'rf'))
30endfunc
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
42