summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0852
blob: cb5cdd8cc95c5873d31614c568a6cee8f424c39b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0852
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.0852
Problem:    findfile() and finddir() are not properly tested.
Solution:   Extend the test and add more. (Dominique Pelle, closes #3880)
Files:	    src/testdir/test_findfile.vim


*** ../vim-8.1.0851/src/testdir/test_findfile.vim	2017-02-23 18:20:26.000000000 +0100
--- src/testdir/test_findfile.vim	2019-01-30 22:11:09.378956665 +0100
***************
*** 1,25 ****
! " Test for findfile()
! "
  func Test_findfile()
!   new
!   let cwd=getcwd()
!   cd ..
  
!   " Tests may be run from a shadow directory, so an extra cd needs to be done to
!   " get above src/
!   if fnamemodify(getcwd(), ':t') != 'src'
!     cd ../.. 
!   else 
!     cd .. 
!   endif
!   set ssl
  
!   call assert_equal('src/testdir/test_findfile.vim', findfile('test_findfile.vim','src/test*'))
!   exe "cd" cwd
    cd ..
!   call assert_equal('testdir/test_findfile.vim', findfile('test_findfile.vim','test*'))
!   call assert_equal('testdir/test_findfile.vim', findfile('test_findfile.vim','testdir'))
  
!   exe "cd" cwd
!   q!
  endfunc
--- 1,169 ----
! " Test findfile() and finddir()
! 
! let s:files = [ 'Xdir1/foo',
!       \         'Xdir1/bar',
!       \         'Xdir1/Xdir2/foo',
!       \         'Xdir1/Xdir2/foobar',
!       \         'Xdir1/Xdir2/Xdir3/bar',
!       \         'Xdir1/Xdir2/Xdir3/barfoo' ]
! 
! func CreateFiles()
!   call mkdir('Xdir1/Xdir2/Xdir3/Xdir2', 'p')
!   for f in s:files
!     call writefile([], f)
!   endfor
! endfunc
! 
! func CleanFiles()
!   " Safer to delete each file even if it's more verbose
!   " than doing a recursive delete('Xdir1', 'rf').
!   for f in s:files
!     call delete(f)
!   endfor
! 
!   call delete('Xdir1/Xdir2/Xdir3/Xdir2', 'd')
!   call delete('Xdir1/Xdir2/Xdir3', 'd')
!   call delete('Xdir1/Xdir2', 'd')
!   call delete('Xdir1', 'd')
! endfunc
! 
! " Test findfile({name} [, {path} [, {count}]])
  func Test_findfile()
!   let save_path = &path
!   let save_shellslash = &shellslash
!   let save_dir = getcwd()
!   set shellslash
!   call CreateFiles()
!   cd Xdir1
!   e Xdir2/foo
! 
!   " With ,, in path, findfile() searches in current directory.
!   set path=,,
!   call assert_equal('foo', findfile('foo'))
!   call assert_equal('bar', findfile('bar'))
!   call assert_equal('',    findfile('foobar'))
! 
!   " Directories should not be found (finddir() finds them).
!   call assert_equal('', findfile('Xdir2'))
! 
!   " With . in 'path', findfile() searches relatively to current file.
!   set path=.
!   call assert_equal('Xdir2/foo',    findfile('foo'))
!   call assert_equal('',             findfile('bar'))
!   call assert_equal('Xdir2/foobar', findfile('foobar'))
! 
!   " Empty {path} 2nd argument is the same as no 2nd argument.
!   call assert_equal('Xdir2/foo', findfile('foo', ''))
!   call assert_equal('',          findfile('bar', ''))
! 
!   " Test with *
!   call assert_equal('Xdir2/foo',       findfile('foo', '*'))
!   call assert_equal('',                findfile('bar', '*'))
!   call assert_equal('Xdir2/Xdir3/bar', findfile('bar', '*/*'))
!   call assert_equal('Xdir2/Xdir3/bar', findfile('bar', 'Xdir2/*'))
!   call assert_equal('Xdir2/Xdir3/bar', findfile('bar', 'Xdir*/Xdir3'))
!   call assert_equal('Xdir2/Xdir3/bar', findfile('bar', '*2/*3'))
! 
!   " Test with **
!   call assert_equal('bar',             findfile('bar', '**'))
!   call assert_equal('Xdir2/Xdir3/bar', findfile('bar', '**/Xdir3'))
!   call assert_equal('Xdir2/Xdir3/bar', findfile('bar', 'Xdir2/**'))
! 
!   call assert_equal('Xdir2/Xdir3/barfoo', findfile('barfoo', '**2'))
!   call assert_equal('',                   findfile('barfoo', '**1'))
!   call assert_equal('Xdir2/foobar',       findfile('foobar', '**1'))
! 
!   " Test with {count} 3rd argument.
!   call assert_equal('bar',                      findfile('bar', '**', 0))
!   call assert_equal('bar',                      findfile('bar', '**', 1))
!   call assert_equal('Xdir2/Xdir3/bar',          findfile('bar', '**', 2))
!   call assert_equal('',                         findfile('bar', '**', 3))
!   call assert_equal(['bar', 'Xdir2/Xdir3/bar'], findfile('bar', '**', -1))
! 
!   " Test upwards search.
!   cd Xdir2/Xdir3
!   call assert_equal('bar',                findfile('bar', ';'))
!   call assert_match('.*/Xdir1/Xdir2/foo', findfile('foo', ';'))
!   call assert_match('.*/Xdir1/Xdir2/foo', findfile('foo', ';', 1))
!   call assert_match('.*/Xdir1/foo',       findfile('foo', ';', 2))
!   call assert_match('.*/Xdir1/foo',       findfile('foo', ';', 2))
!   call assert_match('.*/Xdir1/Xdir2/foo', findfile('foo', 'Xdir2;', 1))
!   call assert_equal('',                   findfile('foo', 'Xdir2;', 2))
! 
!   " List l should have at least 2 values (possibly more if foo file
!   " happens to be found upwards above Xdir1).
!   let l = findfile('foo', ';', -1)
!   call assert_match('.*/Xdir1/Xdir2/foo', l[0])
!   call assert_match('.*/Xdir1/foo',       l[1])
! 
!   " Test upwards search with stop-directory.
!   cd Xdir2
!   let l = findfile('bar', ';' . save_dir . '/Xdir1/Xdir2/', -1)
!   call assert_equal(1, len(l))
!   call assert_match('.*/Xdir1/Xdir2/Xdir3/bar', l[0])
! 
!   let l = findfile('bar', ';' . save_dir . '/Xdir1/', -1)
!   call assert_equal(2, len(l))
!   call assert_match('.*/Xdir1/Xdir2/Xdir3/bar', l[0])
!   call assert_match('.*/Xdir1/bar',             l[1])
! 
!   " Test combined downwards and upwards search from Xdir2/.
!   cd ../..
!   call assert_equal('Xdir3/bar',    findfile('bar', '**;', 1))
!   call assert_match('.*/Xdir1/bar', findfile('bar', '**;', 2))
! 
!   bwipe!
!   exe 'cd  ' . save_dir
!   call CleanFiles()
!   let &path = save_path
!   let &shellslash = save_shellslash
! endfunc
! 
! " Test finddir({name} [, {path} [, {count}]])
! func Test_finddir()
!   let save_path = &path
!   let save_shellslash = &shellslash
!   let save_dir = getcwd()
!   set path=,,
!   call CreateFiles()
!   cd Xdir1
! 
!   call assert_equal('Xdir2', finddir('Xdir2'))
!   call assert_equal('',      finddir('Xdir3'))
! 
!   " Files should not be found (findfile() finds them).
!   call assert_equal('', finddir('foo'))
! 
!   call assert_equal('Xdir2',       finddir('Xdir2', '**'))
!   call assert_equal('Xdir2/Xdir3', finddir('Xdir3', '**'))
! 
!   call assert_equal('Xdir2',               finddir('Xdir2', '**', 1))
!   call assert_equal('Xdir2/Xdir3/Xdir2',   finddir('Xdir2', '**', 2))
!   call assert_equal(['Xdir2',
!         \            'Xdir2/Xdir3/Xdir2'], finddir('Xdir2', '**', -1))
! 
!   call assert_equal('Xdir2',       finddir('Xdir2', '**1'))
!   call assert_equal('Xdir2',       finddir('Xdir2', '**0'))
!   call assert_equal('Xdir2/Xdir3', finddir('Xdir3', '**1'))
!   call assert_equal('',            finddir('Xdir3', '**0'))
! 
!   " Test upwards dir search.
!   cd Xdir2/Xdir3
!   call assert_match('.*/Xdir1', finddir('Xdir1', ';'))
  
!   " Test upwards search with stop-directory.
!   call assert_match('.*/Xdir1', finddir('Xdir1', ';' . save_dir . '/'))
!   call assert_equal('',         finddir('Xdir1', ';' . save_dir . '/Xdir1/'))
  
!   " Test combined downwards and upwards dir search from Xdir2/.
    cd ..
!   call assert_match('.*/Xdir1',       finddir('Xdir1', '**;', 1))
!   call assert_equal('Xdir3/Xdir2',    finddir('Xdir2', '**;', 1))
!   call assert_match('.*/Xdir1/Xdir2', finddir('Xdir2', '**;', 2))
!   call assert_equal('Xdir3',          finddir('Xdir3', '**;', 1))
  
!   exe 'cd  ' . save_dir
!   call CleanFiles()
!   let &path = save_path
!   let &shellslash = save_shellslash
  endfunc
*** ../vim-8.1.0851/src/version.c	2019-01-30 22:01:36.982854408 +0100
--- src/version.c	2019-01-30 22:12:44.338305213 +0100
***************
*** 785,786 ****
--- 785,788 ----
  {   /* Add new patch number below this line */
+ /**/
+     852,
  /**/

-- 
FATHER:    You only killed the bride's father - that's all -
LAUNCELOT: Oh dear, I didn't really mean to...
FATHER:    Didn't mean to?  You put your sword right through his head!
LAUNCELOT: Gosh - Is he all right?
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///