summaryrefslogtreecommitdiff
path: root/test/test_path_upwards.vader
blob: 5e7d576ed43d632acbd21122f157dacc7ce145ca (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
After:
  let g:ale_has_override = {}

Execute(ale#path#Upwards should return the correct path components for 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('')

Execute(ale#path#Upwards should return the correct path components for Windows):
  let g:ale_has_override = {'win32': 1}

  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')