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.
2 function! CheckPath(path) abort
3 return ale#path#IsBufferPath(bufnr(''), ale#path#Simplify(a:path))
9 Execute(ale#path#Simplify should adjust paths correctly):
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')
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')
25 Execute(ale#path#IsBufferPath should match simple relative paths):
26 call ale#test#SetFilename('app/foo.txt')
28 Assert CheckPath('app/foo.txt'), 'No match for foo.txt'
29 Assert !CheckPath('app/bar.txt'), 'Bad match for bar.txt'
31 Execute(ale#path#IsBufferPath should match relative paths with dots):
32 call ale#test#SetFilename('app/foo.txt')
34 " Skip these checks on Windows.
36 Assert CheckPath('../../app/foo.txt'), 'No match for ../../app/foo.txt'
39 Execute(ale#path#IsBufferPath should match absolute paths):
42 Assert CheckPath(getcwd() . '/foo.txt'), 'No match for foo.txt'
43 Assert !CheckPath(getcwd() . '/bar.txt'), 'Bad match for bar.txt'
45 Execute(ale#path#IsBufferPath should match paths beginning with ./):
49 Assert ale#path#IsBufferPath(bufnr(''), './foo.txt'), 'No match for ./foo.txt'
52 Execute(ale#path#IsBufferPath should match if our path ends with the test path):
53 silent file! foo/bar/baz.txt
55 Assert CheckPath('bar/baz.txt'), 'No match for bar/baz.txt'
57 Execute(ale#path#IsBufferPath should match paths with redundant slashes):
60 Assert CheckPath(getcwd() . '////foo.txt'), 'No match for foo.txt'
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>')
68 Execute(ale#path#IsBufferPath should match files in /tmp):
69 call ale#test#SetFilename('app/test.ts')
71 Assert ale#path#IsBufferPath(bufnr(''), tempname() . '/test.ts')
73 Execute(ale#path#IsBufferPath should match Windows paths on Unix):
74 " This test should pass Unix.
76 " Back slashes in paths should be replaced with forward slashes, even though
77 " back slashes are valid in filenames on Unix.
79 call ale#test#SetFilename('app/foo/test.ts')
81 Assert ale#path#IsBufferPath(bufnr(''), 'foo\test.ts')