File: test_path_upwards.vader

package info (click to toggle)
vim-ale 4.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,764 kB
  • sloc: sh: 499; python: 311; perl: 31; makefile: 4; xml: 4; javascript: 1
file content (48 lines) | stat: -rw-r--r-- 1,657 bytes parent folder | download | duplicates (3)
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
Execute(ale#path#Upwards should return the correct path components):
  if has('unix')
    " Absolute paths should include / on the end.
    AssertEqual
    \ ['/foo/bar/baz', '/foo/bar', '/foo', '/'],
    \ ale#path#Upwards('/foo/bar/baz')
    AssertEqual
    \ ['/foo/bar/baz', '/foo/bar', '/foo', '/'],
    \ ale#path#Upwards('/foo/bar/baz///')
    " Relative paths do not.
    AssertEqual
    \ ['foo/bar/baz', 'foo/bar', 'foo'],
    \ ale#path#Upwards('foo/bar/baz')
    AssertEqual
    \ ['foo2/bar', 'foo2'],
    \ ale#path#Upwards('foo//..////foo2////bar')
    " Expect an empty List for empty strings.
    AssertEqual [], ale#path#Upwards('')
  endif

  if has('win32')
    AssertEqual
    \ ['C:\foo\bar\baz', 'C:\foo\bar', 'C:\foo', 'C:\'],
    \ ale#path#Upwards('C:\foo\bar\baz')
    AssertEqual
    \ ['C:\foo\bar\baz', 'C:\foo\bar', 'C:\foo', 'C:\'],
    \ ale#path#Upwards('C:\foo\bar\baz\\\')
    AssertEqual
    \ ['/foo\bar\baz', '/foo\bar', '/foo', '/'],
    \ ale#path#Upwards('/foo/bar/baz')
    AssertEqual
    \ ['foo\bar\baz', 'foo\bar', 'foo'],
    \ ale#path#Upwards('foo/bar/baz')
    AssertEqual
    \ ['foo\bar\baz', 'foo\bar', 'foo'],
    \ ale#path#Upwards('foo\bar\baz')
    " simplify() is used internally, and should sort out \ paths when actually
    " running Windows, which we can't test here.
    AssertEqual
    \ ['foo2\bar', 'foo2'],
    \ ale#path#Upwards('foo//..///foo2////bar')
    " Expect an empty List for empty strings.
    AssertEqual [], ale#path#Upwards('')
    " Paths starting with // return /
    AssertEqual
    \ ['/foo2\bar', '/foo2', '/'],
    \ ale#path#Upwards('//foo//..///foo2////bar')
  endif