]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/test_path_equality.vader

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit 'a39f715c13be3352193ffd9c5b7536b8786eff64' as '.vim/bundle/vim-lsp'
[etc/vim.git] / .vim / bundle / ale / test / test_path_equality.vader
1 Before:
2   function! CheckPath(path) abort
3     return ale#path#IsBufferPath(bufnr(''), ale#path#Simplify(a:path))
4   endfunction
5
6 After:
7   delfunction CheckPath
8
9 Execute(ale#path#Simplify should adjust paths correctly):
10   if has('unix')
11     " Multiple slashes should be removed correctly.
12     AssertEqual '/foo/bar/baz', ale#path#Simplify('////foo///bar///baz')
13     " Back slashes should be converted to forward slashes.
14     " This means some valid filenames are adjusted incorrectly, but in practice
15     " no filenames for code should contain back slashes, and adjusting slashes
16     " like this makes ALE work in MSYS.
17     AssertEqual 'foo/bar/baz', ale#path#Simplify('foo\bar\baz')
18   else
19     " Multiple slashes should be removed correctly.
20     AssertEqual '\foo\bar\baz', ale#path#Simplify('\\\foo\bar\baz')
21     " Forward slashes should be replaced with back slashes.
22     AssertEqual 'foo\bar\baz', ale#path#Simplify('foo/bar/baz')
23   endif
24
25 Execute(ale#path#IsBufferPath should match simple relative paths):
26   call ale#test#SetFilename('app/foo.txt')
27
28   Assert CheckPath('app/foo.txt'), 'No match for foo.txt'
29   Assert !CheckPath('app/bar.txt'), 'Bad match for bar.txt'
30
31 Execute(ale#path#IsBufferPath should match relative paths with dots):
32   call ale#test#SetFilename('app/foo.txt')
33
34   " Skip these checks on Windows.
35   if !has('win32')
36     Assert CheckPath('../../app/foo.txt'), 'No match for ../../app/foo.txt'
37   endif
38
39 Execute(ale#path#IsBufferPath should match absolute paths):
40   silent file! foo.txt
41
42   Assert CheckPath(getcwd() . '/foo.txt'), 'No match for foo.txt'
43   Assert !CheckPath(getcwd() . '/bar.txt'), 'Bad match for bar.txt'
44
45 Execute(ale#path#IsBufferPath should match paths beginning with ./):
46   silent file! foo.txt
47
48   if !has('win32')
49     Assert ale#path#IsBufferPath(bufnr(''), './foo.txt'), 'No match for ./foo.txt'
50   endif
51
52 Execute(ale#path#IsBufferPath should match if our path ends with the test path):
53   silent file! foo/bar/baz.txt
54
55   Assert CheckPath('bar/baz.txt'), 'No match for bar/baz.txt'
56
57 Execute(ale#path#IsBufferPath should match paths with redundant slashes):
58   silent file! foo.txt
59
60   Assert CheckPath(getcwd() . '////foo.txt'), 'No match for foo.txt'
61
62 Execute(ale#path#IsBufferPath should accept various names for stdin):
63   Assert ale#path#IsBufferPath(bufnr(''), '-')
64   Assert ale#path#IsBufferPath(bufnr(''), 'stdin')
65   Assert ale#path#IsBufferPath(bufnr(''), '<stdin>')
66   Assert ale#path#IsBufferPath(bufnr(''), '<somethingelse>')
67
68 Execute(ale#path#IsBufferPath should match files in /tmp):
69   call ale#test#SetFilename('app/test.ts')
70
71   Assert ale#path#IsBufferPath(bufnr(''), tempname() . '/test.ts')
72
73 Execute(ale#path#IsBufferPath should match Windows paths on Unix):
74   " This test should pass Unix.
75   "
76   " Back slashes in paths should be replaced with forward slashes, even though
77   " back slashes are valid in filenames on Unix.
78   if has('unix')
79     call ale#test#SetFilename('app/foo/test.ts')
80
81     Assert ale#path#IsBufferPath(bufnr(''), 'foo\test.ts')
82   endif