summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-05-05 23:03:19 +0100
committerw0rp <devw0rp@gmail.com>2017-05-05 23:03:19 +0100
commitab9afaa2bf446ed9db32f5ab43081e7f28cc1358 (patch)
tree56077678593f81b2b981fcaab81a373358f6fc60 /test
parent6b15c7c9fd56edf1d63bc92c81c86afb7f6d3b6e (diff)
downloadale-ab9afaa2bf446ed9db32f5ab43081e7f28cc1358.zip
Add a has() wrapper we can override for tests, and add a function for generating paths up to the root directory to search through
Diffstat (limited to 'test')
-rw-r--r--test/test_path_upwards.vader46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/test_path_upwards.vader b/test/test_path_upwards.vader
new file mode 100644
index 00000000..2f7b2c0f
--- /dev/null
+++ b/test/test_path_upwards.vader
@@ -0,0 +1,46 @@
+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('')