1" Test 'autochdir' behavior
2
3source check.vim
4CheckOption autochdir
5
6func Test_set_filename()
7  let cwd = getcwd()
8  call test_autochdir()
9  set acd
10
11  let s:li = []
12  autocmd DirChanged auto call add(s:li, "autocd")
13  autocmd DirChanged auto call add(s:li, expand("<afile>"))
14
15  new
16  w samples/Xtest
17  call assert_equal("Xtest", expand('%'))
18  call assert_equal("samples", substitute(getcwd(), '.*/\(\k*\)', '\1', ''))
19  call assert_equal(["autocd", getcwd()], s:li)
20
21  bwipe!
22  au! DirChanged
23  set noacd
24  call chdir(cwd)
25  call delete('samples/Xtest')
26endfunc
27
28func Test_verbose_pwd()
29  let cwd = getcwd()
30  call test_autochdir()
31
32  edit global.txt
33  call assert_match('\[global\].*testdir$', execute('verbose pwd'))
34
35  call mkdir('Xautodir')
36  split Xautodir/local.txt
37  lcd Xautodir
38  call assert_match('\[window\].*testdir[/\\]Xautodir', execute('verbose pwd'))
39
40  set acd
41  wincmd w
42  call assert_match('\[autochdir\].*testdir$', execute('verbose pwd'))
43  execute 'lcd' cwd
44  call assert_match('\[window\].*testdir$', execute('verbose pwd'))
45  execute 'tcd' cwd
46  call assert_match('\[tabpage\].*testdir$', execute('verbose pwd'))
47  execute 'cd' cwd
48  call assert_match('\[global\].*testdir$', execute('verbose pwd'))
49  edit
50  call assert_match('\[autochdir\].*testdir$', execute('verbose pwd'))
51  wincmd w
52  call assert_match('\[autochdir\].*testdir[/\\]Xautodir', execute('verbose pwd'))
53  set noacd
54  call assert_match('\[autochdir\].*testdir[/\\]Xautodir', execute('verbose pwd'))
55  wincmd w
56  call assert_match('\[global\].*testdir', execute('verbose pwd'))
57  wincmd w
58  call assert_match('\[window\].*testdir[/\\]Xautodir', execute('verbose pwd'))
59
60  bwipe!
61  call chdir(cwd)
62  call delete('Xautodir', 'rf')
63endfunc
64
65" vim: shiftwidth=2 sts=2 expandtab
66