comparison src/testdir/test_getcwd.vim @ 15406:63b02fcf1361 v8.1.0711

patch 8.1.0711: test files still use function! commit https://github.com/vim/vim/commit/1e1153600c0377472d62cc553173fe555ddcf5a7 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jan 9 23:01:02 2019 +0100 patch 8.1.0711: test files still use function! Problem: Test files still use function!. Solution: Remove the exclamation mark. Fix overwriting a function.
author Bram Moolenaar <Bram@vim.org>
date Wed, 09 Jan 2019 23:15:05 +0100
parents ae62baca938c
children 8c3a1bd270bb
comparison
equal deleted inserted replaced
15405:3a8785d45112 15406:63b02fcf1361
1 function! GetCwdInfo(win, tab) 1 func GetCwdInfo(win, tab)
2 let tab_changed = 0 2 let tab_changed = 0
3 let mod = ":t" 3 let mod = ":t"
4 if a:tab > 0 && a:tab != tabpagenr() 4 if a:tab > 0 && a:tab != tabpagenr()
5 let tab_changed = 1 5 let tab_changed = 1
6 exec "tabnext " . a:tab 6 exec "tabnext " . a:tab
7 endif 7 endif
8 let bufname = fnamemodify(bufname(winbufnr(a:win)), mod) 8 let bufname = fnamemodify(bufname(winbufnr(a:win)), mod)
9 if tab_changed 9 if tab_changed
10 tabprevious 10 tabprevious
11 endif 11 endif
12 if a:win == 0 && a:tab == 0 12 if a:win == 0 && a:tab == 0
13 let dirname = fnamemodify(getcwd(), mod) 13 let dirname = fnamemodify(getcwd(), mod)
14 let lflag = haslocaldir() 14 let lflag = haslocaldir()
15 elseif a:tab == 0 15 elseif a:tab == 0
16 let dirname = fnamemodify(getcwd(a:win), mod) 16 let dirname = fnamemodify(getcwd(a:win), mod)
17 let lflag = haslocaldir(a:win) 17 let lflag = haslocaldir(a:win)
18 else 18 else
19 let dirname = fnamemodify(getcwd(a:win, a:tab), mod) 19 let dirname = fnamemodify(getcwd(a:win, a:tab), mod)
20 let lflag = haslocaldir(a:win, a:tab) 20 let lflag = haslocaldir(a:win, a:tab)
21 endif 21 endif
22 return bufname . ' ' . dirname . ' ' . lflag 22 return bufname . ' ' . dirname . ' ' . lflag
23 endfunction 23 endfunc
24 24
25 " Do all test in a separate window to avoid E211 when we recursively 25 " Do all test in a separate window to avoid E211 when we recursively
26 " delete the Xtopdir directory during cleanup 26 " delete the Xtopdir directory during cleanup
27 function SetUp() 27 function SetUp()
28 set visualbell 28 set visualbell
29 set nocp viminfo+=nviminfo 29 set nocp viminfo+=nviminfo
30 30
31 " On windows a swapfile in Xtopdir prevents it from being cleaned up. 31 " On windows a swapfile in Xtopdir prevents it from being cleaned up.
32 set noswapfile 32 set noswapfile
33 33
34 " On windows a stale "Xtopdir" directory may exist, remove it so that 34 " On windows a stale "Xtopdir" directory may exist, remove it so that
35 " we start from a clean state. 35 " we start from a clean state.
36 call delete("Xtopdir", "rf") 36 call delete("Xtopdir", "rf")
37 new 37 new
38 call mkdir('Xtopdir') 38 call mkdir('Xtopdir')
39 cd Xtopdir 39 cd Xtopdir
40 let g:topdir = getcwd() 40 let g:topdir = getcwd()
41 call mkdir('Xdir1') 41 call mkdir('Xdir1')
42 call mkdir('Xdir2') 42 call mkdir('Xdir2')
43 call mkdir('Xdir3') 43 call mkdir('Xdir3')
44 endfunction 44 endfunction
45 45
46 let g:cwd=getcwd() 46 let g:cwd=getcwd()
47 function TearDown() 47 function TearDown()
48 q 48 q
49 exec "cd " . g:cwd 49 exec "cd " . g:cwd
50 call delete("Xtopdir", "rf") 50 call delete("Xtopdir", "rf")
51 endfunction 51 endfunction
52 52
53 function Test_GetCwd() 53 function Test_GetCwd()
54 new a 54 new a
55 new b 55 new b
56 new c 56 new c
57 3wincmd w 57 3wincmd w
58 lcd Xdir1 58 lcd Xdir1
59 call assert_equal("a Xdir1 1", GetCwdInfo(0, 0)) 59 call assert_equal("a Xdir1 1", GetCwdInfo(0, 0))
60 call assert_equal(g:topdir, getcwd(-1)) 60 call assert_equal(g:topdir, getcwd(-1))
61 wincmd W 61 wincmd W
62 call assert_equal("b Xtopdir 0", GetCwdInfo(0, 0)) 62 call assert_equal("b Xtopdir 0", GetCwdInfo(0, 0))
63 call assert_equal(g:topdir, getcwd(-1)) 63 call assert_equal(g:topdir, getcwd(-1))
64 wincmd W 64 wincmd W
65 lcd Xdir3 65 lcd Xdir3
66 call assert_equal("c Xdir3 1", GetCwdInfo(0, 0)) 66 call assert_equal("c Xdir3 1", GetCwdInfo(0, 0))
67 call assert_equal("a Xdir1 1", GetCwdInfo(bufwinnr("a"), 0)) 67 call assert_equal("a Xdir1 1", GetCwdInfo(bufwinnr("a"), 0))
68 call assert_equal("b Xtopdir 0", GetCwdInfo(bufwinnr("b"), 0)) 68 call assert_equal("b Xtopdir 0", GetCwdInfo(bufwinnr("b"), 0))
69 call assert_equal("c Xdir3 1", GetCwdInfo(bufwinnr("c"), 0)) 69 call assert_equal("c Xdir3 1", GetCwdInfo(bufwinnr("c"), 0))
70 call assert_equal(g:topdir, getcwd(-1)) 70 call assert_equal(g:topdir, getcwd(-1))
71 wincmd W 71 wincmd W
72 call assert_equal("a Xdir1 1", GetCwdInfo(bufwinnr("a"), tabpagenr())) 72 call assert_equal("a Xdir1 1", GetCwdInfo(bufwinnr("a"), tabpagenr()))
73 call assert_equal("b Xtopdir 0", GetCwdInfo(bufwinnr("b"), tabpagenr())) 73 call assert_equal("b Xtopdir 0", GetCwdInfo(bufwinnr("b"), tabpagenr()))
74 call assert_equal("c Xdir3 1", GetCwdInfo(bufwinnr("c"), tabpagenr())) 74 call assert_equal("c Xdir3 1", GetCwdInfo(bufwinnr("c"), tabpagenr()))
75 call assert_equal(g:topdir, getcwd(-1)) 75 call assert_equal(g:topdir, getcwd(-1))
76 76
77 tabnew x 77 tabnew x
78 new y 78 new y
79 new z 79 new z
80 3wincmd w 80 3wincmd w
81 call assert_equal("x Xtopdir 0", GetCwdInfo(0, 0)) 81 call assert_equal("x Xtopdir 0", GetCwdInfo(0, 0))
82 call assert_equal(g:topdir, getcwd(-1)) 82 call assert_equal(g:topdir, getcwd(-1))
83 wincmd W 83 wincmd W
84 lcd Xdir2 84 lcd Xdir2
85 call assert_equal("y Xdir2 1", GetCwdInfo(0, 0)) 85 call assert_equal("y Xdir2 1", GetCwdInfo(0, 0))
86 call assert_equal(g:topdir, getcwd(-1)) 86 call assert_equal(g:topdir, getcwd(-1))
87 wincmd W 87 wincmd W
88 lcd Xdir3 88 lcd Xdir3
89 call assert_equal("z Xdir3 1", GetCwdInfo(0, 0)) 89 call assert_equal("z Xdir3 1", GetCwdInfo(0, 0))
90 call assert_equal("x Xtopdir 0", GetCwdInfo(bufwinnr("x"), 0)) 90 call assert_equal("x Xtopdir 0", GetCwdInfo(bufwinnr("x"), 0))
91 call assert_equal("y Xdir2 1", GetCwdInfo(bufwinnr("y"), 0)) 91 call assert_equal("y Xdir2 1", GetCwdInfo(bufwinnr("y"), 0))
92 call assert_equal("z Xdir3 1", GetCwdInfo(bufwinnr("z"), 0)) 92 call assert_equal("z Xdir3 1", GetCwdInfo(bufwinnr("z"), 0))
93 call assert_equal(g:topdir, getcwd(-1)) 93 call assert_equal(g:topdir, getcwd(-1))
94 let tp_nr = tabpagenr() 94 let tp_nr = tabpagenr()
95 tabrewind 95 tabrewind
96 call assert_equal("x Xtopdir 0", GetCwdInfo(3, tp_nr)) 96 call assert_equal("x Xtopdir 0", GetCwdInfo(3, tp_nr))
97 call assert_equal("y Xdir2 1", GetCwdInfo(2, tp_nr)) 97 call assert_equal("y Xdir2 1", GetCwdInfo(2, tp_nr))
98 call assert_equal("z Xdir3 1", GetCwdInfo(1, tp_nr)) 98 call assert_equal("z Xdir3 1", GetCwdInfo(1, tp_nr))
99 call assert_equal(g:topdir, getcwd(-1)) 99 call assert_equal(g:topdir, getcwd(-1))
100 endfunc 100 endfunc
101 101
102 function Test_GetCwd_lcd_shellslash() 102 function Test_GetCwd_lcd_shellslash()
103 new 103 new
104 let root = fnamemodify('/', ':p') 104 let root = fnamemodify('/', ':p')
105 exe 'lcd '.root 105 exe 'lcd '.root
106 let cwd = getcwd() 106 let cwd = getcwd()
107 if !exists('+shellslash') || &shellslash 107 if !exists('+shellslash') || &shellslash
108 call assert_equal(cwd[-1:], '/') 108 call assert_equal(cwd[-1:], '/')
109 else 109 else
110 call assert_equal(cwd[-1:], '\') 110 call assert_equal(cwd[-1:], '\')
111 endif 111 endif
112 endfunc 112 endfunc