Mercurial > vim
annotate src/testdir/test_findfile.vim @ 15930:e580c9d75443 v8.1.0971
patch 8.1.0971: failure for selecting quoted text object moves cursor
commit https://github.com/vim/vim/commit/55d3bdbbe2bfc7a78b4aa17763788dbddf87cab0
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Feb 22 15:04:17 2019 +0100
patch 8.1.0971: failure for selecting quoted text object moves cursor
Problem: Failure for selecting quoted text object moves cursor.
Solution: Restore the Visual selection on failure. (Christian Brabandt,
closes #4024)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 22 Feb 2019 15:15:05 +0100 |
parents | 6839f99d2269 |
children | 73ddc462979d |
rev | line source |
---|---|
15689
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
1 " Test findfile() and finddir() |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
2 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
3 let s:files = [ 'Xdir1/foo', |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
4 \ 'Xdir1/bar', |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
5 \ 'Xdir1/Xdir2/foo', |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
6 \ 'Xdir1/Xdir2/foobar', |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
7 \ 'Xdir1/Xdir2/Xdir3/bar', |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
8 \ 'Xdir1/Xdir2/Xdir3/barfoo' ] |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
9 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
10 func CreateFiles() |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
11 call mkdir('Xdir1/Xdir2/Xdir3/Xdir2', 'p') |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
12 for f in s:files |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
13 call writefile([], f) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
14 endfor |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
15 endfunc |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
16 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
17 func CleanFiles() |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
18 " Safer to delete each file even if it's more verbose |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
19 " than doing a recursive delete('Xdir1', 'rf'). |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
20 for f in s:files |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
21 call delete(f) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
22 endfor |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
23 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
24 call delete('Xdir1/Xdir2/Xdir3/Xdir2', 'd') |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
25 call delete('Xdir1/Xdir2/Xdir3', 'd') |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
26 call delete('Xdir1/Xdir2', 'd') |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
27 call delete('Xdir1', 'd') |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
28 endfunc |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
29 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
30 " Test findfile({name} [, {path} [, {count}]]) |
10940
a479b7064550
patch 8.0.0359: 'number' and 'relativenumber' are not properly tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 func Test_findfile() |
15689
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
32 let save_path = &path |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
33 let save_shellslash = &shellslash |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
34 let save_dir = getcwd() |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
35 set shellslash |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
36 call CreateFiles() |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
37 cd Xdir1 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
38 e Xdir2/foo |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
39 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
40 " With ,, in path, findfile() searches in current directory. |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
41 set path=,, |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
42 call assert_equal('foo', findfile('foo')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
43 call assert_equal('bar', findfile('bar')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
44 call assert_equal('', findfile('foobar')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
45 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
46 " Directories should not be found (finddir() finds them). |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
47 call assert_equal('', findfile('Xdir2')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
48 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
49 " With . in 'path', findfile() searches relatively to current file. |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
50 set path=. |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
51 call assert_equal('Xdir2/foo', findfile('foo')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
52 call assert_equal('', findfile('bar')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
53 call assert_equal('Xdir2/foobar', findfile('foobar')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
54 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
55 " Empty {path} 2nd argument is the same as no 2nd argument. |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
56 call assert_equal('Xdir2/foo', findfile('foo', '')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
57 call assert_equal('', findfile('bar', '')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
58 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
59 " Test with * |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
60 call assert_equal('Xdir2/foo', findfile('foo', '*')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
61 call assert_equal('', findfile('bar', '*')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
62 call assert_equal('Xdir2/Xdir3/bar', findfile('bar', '*/*')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
63 call assert_equal('Xdir2/Xdir3/bar', findfile('bar', 'Xdir2/*')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
64 call assert_equal('Xdir2/Xdir3/bar', findfile('bar', 'Xdir*/Xdir3')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
65 call assert_equal('Xdir2/Xdir3/bar', findfile('bar', '*2/*3')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
66 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
67 " Test with ** |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
68 call assert_equal('bar', findfile('bar', '**')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
69 call assert_equal('Xdir2/Xdir3/bar', findfile('bar', '**/Xdir3')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
70 call assert_equal('Xdir2/Xdir3/bar', findfile('bar', 'Xdir2/**')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
71 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
72 call assert_equal('Xdir2/Xdir3/barfoo', findfile('barfoo', '**2')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
73 call assert_equal('', findfile('barfoo', '**1')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
74 call assert_equal('Xdir2/foobar', findfile('foobar', '**1')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
75 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
76 " Test with {count} 3rd argument. |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
77 call assert_equal('bar', findfile('bar', '**', 0)) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
78 call assert_equal('bar', findfile('bar', '**', 1)) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
79 call assert_equal('Xdir2/Xdir3/bar', findfile('bar', '**', 2)) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
80 call assert_equal('', findfile('bar', '**', 3)) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
81 call assert_equal(['bar', 'Xdir2/Xdir3/bar'], findfile('bar', '**', -1)) |
10940
a479b7064550
patch 8.0.0359: 'number' and 'relativenumber' are not properly tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
82 |
15689
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
83 " Test upwards search. |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
84 cd Xdir2/Xdir3 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
85 call assert_equal('bar', findfile('bar', ';')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
86 call assert_match('.*/Xdir1/Xdir2/foo', findfile('foo', ';')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
87 call assert_match('.*/Xdir1/Xdir2/foo', findfile('foo', ';', 1)) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
88 call assert_match('.*/Xdir1/foo', findfile('foo', ';', 2)) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
89 call assert_match('.*/Xdir1/foo', findfile('foo', ';', 2)) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
90 call assert_match('.*/Xdir1/Xdir2/foo', findfile('foo', 'Xdir2;', 1)) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
91 call assert_equal('', findfile('foo', 'Xdir2;', 2)) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
92 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
93 " List l should have at least 2 values (possibly more if foo file |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
94 " happens to be found upwards above Xdir1). |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
95 let l = findfile('foo', ';', -1) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
96 call assert_match('.*/Xdir1/Xdir2/foo', l[0]) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
97 call assert_match('.*/Xdir1/foo', l[1]) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
98 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
99 " Test upwards search with stop-directory. |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
100 cd Xdir2 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
101 let l = findfile('bar', ';' . save_dir . '/Xdir1/Xdir2/', -1) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
102 call assert_equal(1, len(l)) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
103 call assert_match('.*/Xdir1/Xdir2/Xdir3/bar', l[0]) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
104 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
105 let l = findfile('bar', ';' . save_dir . '/Xdir1/', -1) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
106 call assert_equal(2, len(l)) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
107 call assert_match('.*/Xdir1/Xdir2/Xdir3/bar', l[0]) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
108 call assert_match('.*/Xdir1/bar', l[1]) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
109 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
110 " Test combined downwards and upwards search from Xdir2/. |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
111 cd ../.. |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
112 call assert_equal('Xdir3/bar', findfile('bar', '**;', 1)) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
113 call assert_match('.*/Xdir1/bar', findfile('bar', '**;', 2)) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
114 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
115 bwipe! |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
116 exe 'cd ' . save_dir |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
117 call CleanFiles() |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
118 let &path = save_path |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
119 let &shellslash = save_shellslash |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
120 endfunc |
10940
a479b7064550
patch 8.0.0359: 'number' and 'relativenumber' are not properly tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
121 |
15736
6839f99d2269
patch 8.1.0875: not all errors of marks and findfile()/finddir() are tested
Bram Moolenaar <Bram@vim.org>
parents:
15689
diff
changeset
|
122 func Test_findfile_error() |
6839f99d2269
patch 8.1.0875: not all errors of marks and findfile()/finddir() are tested
Bram Moolenaar <Bram@vim.org>
parents:
15689
diff
changeset
|
123 call assert_fails('call findfile([])', 'E730:') |
6839f99d2269
patch 8.1.0875: not all errors of marks and findfile()/finddir() are tested
Bram Moolenaar <Bram@vim.org>
parents:
15689
diff
changeset
|
124 call assert_fails('call findfile("x", [])', 'E730:') |
6839f99d2269
patch 8.1.0875: not all errors of marks and findfile()/finddir() are tested
Bram Moolenaar <Bram@vim.org>
parents:
15689
diff
changeset
|
125 call assert_fails('call findfile("x", "", [])', 'E745:') |
6839f99d2269
patch 8.1.0875: not all errors of marks and findfile()/finddir() are tested
Bram Moolenaar <Bram@vim.org>
parents:
15689
diff
changeset
|
126 call assert_fails('call findfile("x", "**x")', 'E343:') |
6839f99d2269
patch 8.1.0875: not all errors of marks and findfile()/finddir() are tested
Bram Moolenaar <Bram@vim.org>
parents:
15689
diff
changeset
|
127 call assert_fails('call findfile("x", repeat("x", 5000))', 'E854:') |
6839f99d2269
patch 8.1.0875: not all errors of marks and findfile()/finddir() are tested
Bram Moolenaar <Bram@vim.org>
parents:
15689
diff
changeset
|
128 endfunc |
6839f99d2269
patch 8.1.0875: not all errors of marks and findfile()/finddir() are tested
Bram Moolenaar <Bram@vim.org>
parents:
15689
diff
changeset
|
129 |
15689
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
130 " Test finddir({name} [, {path} [, {count}]]) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
131 func Test_finddir() |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
132 let save_path = &path |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
133 let save_shellslash = &shellslash |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
134 let save_dir = getcwd() |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
135 set path=,, |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
136 call CreateFiles() |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
137 cd Xdir1 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
138 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
139 call assert_equal('Xdir2', finddir('Xdir2')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
140 call assert_equal('', finddir('Xdir3')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
141 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
142 " Files should not be found (findfile() finds them). |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
143 call assert_equal('', finddir('foo')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
144 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
145 call assert_equal('Xdir2', finddir('Xdir2', '**')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
146 call assert_equal('Xdir2/Xdir3', finddir('Xdir3', '**')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
147 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
148 call assert_equal('Xdir2', finddir('Xdir2', '**', 1)) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
149 call assert_equal('Xdir2/Xdir3/Xdir2', finddir('Xdir2', '**', 2)) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
150 call assert_equal(['Xdir2', |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
151 \ 'Xdir2/Xdir3/Xdir2'], finddir('Xdir2', '**', -1)) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
152 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
153 call assert_equal('Xdir2', finddir('Xdir2', '**1')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
154 call assert_equal('Xdir2', finddir('Xdir2', '**0')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
155 call assert_equal('Xdir2/Xdir3', finddir('Xdir3', '**1')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
156 call assert_equal('', finddir('Xdir3', '**0')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
157 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
158 " Test upwards dir search. |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
159 cd Xdir2/Xdir3 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
160 call assert_match('.*/Xdir1', finddir('Xdir1', ';')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
161 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
162 " Test upwards search with stop-directory. |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
163 call assert_match('.*/Xdir1', finddir('Xdir1', ';' . save_dir . '/')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
164 call assert_equal('', finddir('Xdir1', ';' . save_dir . '/Xdir1/')) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
165 |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
166 " Test combined downwards and upwards dir search from Xdir2/. |
10940
a479b7064550
patch 8.0.0359: 'number' and 'relativenumber' are not properly tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
167 cd .. |
15689
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
168 call assert_match('.*/Xdir1', finddir('Xdir1', '**;', 1)) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
169 call assert_equal('Xdir3/Xdir2', finddir('Xdir2', '**;', 1)) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
170 call assert_match('.*/Xdir1/Xdir2', finddir('Xdir2', '**;', 2)) |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
171 call assert_equal('Xdir3', finddir('Xdir3', '**;', 1)) |
10940
a479b7064550
patch 8.0.0359: 'number' and 'relativenumber' are not properly tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
172 |
15689
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
173 exe 'cd ' . save_dir |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
174 call CleanFiles() |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
175 let &path = save_path |
977a05589b65
patch 8.1.0852: findfile() and finddir() are not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
10940
diff
changeset
|
176 let &shellslash = save_shellslash |
10940
a479b7064550
patch 8.0.0359: 'number' and 'relativenumber' are not properly tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
177 endfunc |
15736
6839f99d2269
patch 8.1.0875: not all errors of marks and findfile()/finddir() are tested
Bram Moolenaar <Bram@vim.org>
parents:
15689
diff
changeset
|
178 |
6839f99d2269
patch 8.1.0875: not all errors of marks and findfile()/finddir() are tested
Bram Moolenaar <Bram@vim.org>
parents:
15689
diff
changeset
|
179 func Test_finddir_error() |
6839f99d2269
patch 8.1.0875: not all errors of marks and findfile()/finddir() are tested
Bram Moolenaar <Bram@vim.org>
parents:
15689
diff
changeset
|
180 call assert_fails('call finddir([])', 'E730:') |
6839f99d2269
patch 8.1.0875: not all errors of marks and findfile()/finddir() are tested
Bram Moolenaar <Bram@vim.org>
parents:
15689
diff
changeset
|
181 call assert_fails('call finddir("x", [])', 'E730:') |
6839f99d2269
patch 8.1.0875: not all errors of marks and findfile()/finddir() are tested
Bram Moolenaar <Bram@vim.org>
parents:
15689
diff
changeset
|
182 call assert_fails('call finddir("x", "", [])', 'E745:') |
6839f99d2269
patch 8.1.0875: not all errors of marks and findfile()/finddir() are tested
Bram Moolenaar <Bram@vim.org>
parents:
15689
diff
changeset
|
183 call assert_fails('call finddir("x", "**x")', 'E343:') |
6839f99d2269
patch 8.1.0875: not all errors of marks and findfile()/finddir() are tested
Bram Moolenaar <Bram@vim.org>
parents:
15689
diff
changeset
|
184 call assert_fails('call finddir("x", repeat("x", 5000))', 'E854:') |
6839f99d2269
patch 8.1.0875: not all errors of marks and findfile()/finddir() are tested
Bram Moolenaar <Bram@vim.org>
parents:
15689
diff
changeset
|
185 endfunc |