summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2019-02-22 00:35:53 +0000
committerw0rp <devw0rp@gmail.com>2019-02-22 00:35:53 +0000
commitf8aeb5c5a45b57a35d1572176e345173c6e4de61 (patch)
tree15fb106b46f94d16f90e73fabd6fc7ac03ccbb03 /test
parentffa45fa3fb44ade28c64aa8f0a21acd71c903a2a (diff)
downloadale-f8aeb5c5a45b57a35d1572176e345173c6e4de61.zip
#2132 - Make most foo_callback options work as foo
Diffstat (limited to 'test')
-rw-r--r--test/test_linter_defintion_processing.vader125
1 files changed, 117 insertions, 8 deletions
diff --git a/test/test_linter_defintion_processing.vader b/test/test_linter_defintion_processing.vader
index 0f54cf0e..a78b9838 100644
--- a/test/test_linter_defintion_processing.vader
+++ b/test/test_linter_defintion_processing.vader
@@ -461,6 +461,18 @@ Execute(PreProcess should complain about using language and language_callback to
AssertThrows call ale#linter#PreProcess('testft', g:linter)
AssertEqual 'Only one of `language` or `language_callback` should be set', g:vader_exception
+Execute(PreProcess should complain about invalid language values):
+ let g:linter = {
+ \ 'name': 'x',
+ \ 'lsp': 'socket',
+ \ 'address_callback': 'X',
+ \ 'language': 0,
+ \ 'project_root_callback': 'x',
+ \}
+
+ AssertThrows call ale#linter#PreProcess('testft', g:linter)
+ AssertEqual '`language` must be a String or Funcref', g:vader_exception
+
Execute(PreProcess should use the filetype as the language string by default):
let g:linter = {
\ 'name': 'x',
@@ -471,6 +483,17 @@ Execute(PreProcess should use the filetype as the language string by default):
AssertEqual 'testft', ale#linter#PreProcess('testft', g:linter).language_callback(0)
+Execute(PreProcess should allow language to be set to a callback):
+ let g:linter = {
+ \ 'name': 'x',
+ \ 'lsp': 'socket',
+ \ 'address_callback': 'X',
+ \ 'language': {-> 'foo'},
+ \ 'project_root_callback': 'x',
+ \}
+
+ AssertEqual 'foo', ale#linter#PreProcess('testft', g:linter).language_callback(0)
+
Execute(PreProcess should require an address_callback for LSP socket configurations):
let g:linter = {
\ 'name': 'x',
@@ -478,7 +501,7 @@ Execute(PreProcess should require an address_callback for LSP socket configurati
\}
AssertThrows call ale#linter#PreProcess('testft', g:linter)
- AssertEqual '`address_callback` must be defined for getting the LSP address', g:vader_exception
+ AssertEqual '`address` or `address_callback` must be defined for getting the LSP address', g:vader_exception
Execute(PreProcess should complain about address_callback for non-LSP linters):
let g:linter = {
@@ -490,7 +513,50 @@ Execute(PreProcess should complain about address_callback for non-LSP linters):
\}
AssertThrows call ale#linter#PreProcess('testft', g:linter)
- AssertEqual '`address_callback` cannot be used when lsp != ''socket''', g:vader_exception
+ AssertEqual '`address` or `address_callback` cannot be used when lsp != ''socket''', g:vader_exception
+
+Execute(PreProcess accept valid address_callback values):
+ let g:linter = ale#linter#PreProcess('testft', {
+ \ 'name': 'x',
+ \ 'lsp': 'socket',
+ \ 'address_callback': {-> 'foo:123'},
+ \ 'language': 'x',
+ \ 'project_root_callback': 'x',
+ \})
+
+ AssertEqual 'foo:123', ale#linter#GetAddress(0, g:linter)
+
+Execute(PreProcess accept address as a String):
+ let g:linter = ale#linter#PreProcess('testft', {
+ \ 'name': 'x',
+ \ 'lsp': 'socket',
+ \ 'address': 'foo:123',
+ \ 'language': 'x',
+ \ 'project_root_callback': 'x',
+ \})
+
+ AssertEqual 'foo:123', ale#linter#GetAddress(0, g:linter)
+
+Execute(PreProcess accept address as a Function):
+ let g:linter = ale#linter#PreProcess('testft', {
+ \ 'name': 'x',
+ \ 'lsp': 'socket',
+ \ 'address': {-> 'foo:123'},
+ \ 'language': 'x',
+ \ 'project_root_callback': 'x',
+ \})
+
+ AssertEqual 'foo:123', ale#linter#GetAddress(0, g:linter)
+
+Execute(PreProcess should complain about invalid address values):
+ AssertThrows call ale#linter#PreProcess('testft', {
+ \ 'name': 'x',
+ \ 'lsp': 'socket',
+ \ 'address': 0,
+ \ 'language': 'x',
+ \ 'project_root_callback': 'x',
+ \})
+ AssertEqual '`address` must be a String or Function if defined', g:vader_exception
Execute(PreProcess should complain about using initialization_options and initialization_options_callback together):
let g:linter = {
@@ -517,6 +583,41 @@ Execute(PreProcess should throw when initialization_options_callback is not a ca
\})
AssertEqual '`initialization_options_callback` must be a callback if defined', g:vader_exception
+Execute(PreProcess should throw when initialization_options is not a Dictionary or callback):
+ AssertThrows call ale#linter#PreProcess('testft', {
+ \ 'name': 'foo',
+ \ 'lsp': 'socket',
+ \ 'address_callback': 'X',
+ \ 'language': 'x',
+ \ 'project_root_callback': 'x',
+ \ 'initialization_options': 0,
+ \})
+ AssertEqual '`initialization_options` must be a String or Function if defined', g:vader_exception
+
+Execute(PreProcess should accept initialization_options as a Dictionary):
+ let g:linter = ale#linter#PreProcess('testft', {
+ \ 'name': 'foo',
+ \ 'lsp': 'socket',
+ \ 'address_callback': 'X',
+ \ 'language': 'x',
+ \ 'project_root_callback': 'x',
+ \ 'initialization_options': {'foo': v:true},
+ \})
+
+ AssertEqual {'foo': v:true}, ale#lsp_linter#GetOptions(0, g:linter)
+
+Execute(PreProcess should accept initialization_options as a Funcref):
+ let g:linter = ale#linter#PreProcess('testft', {
+ \ 'name': 'foo',
+ \ 'lsp': 'socket',
+ \ 'address_callback': 'X',
+ \ 'language': 'x',
+ \ 'project_root_callback': 'x',
+ \ 'initialization_options': {-> {'foo': v:true}},
+ \})
+
+ AssertEqual {'foo': v:true}, ale#lsp_linter#GetOptions(0, g:linter)
+
Execute(PreProcess should complain about using lsp_config and lsp_config_callback together):
let g:linter = {
\ 'name': 'x',
@@ -543,22 +644,30 @@ Execute(PreProcess should throw when lsp_config_callback is not a callback):
AssertEqual '`lsp_config_callback` must be a callback if defined', g:vader_exception
Execute(PreProcess should accept LSP configuration options via lsp_config):
- let g:ale_lsp_configuration = {
- \ 'foo': 'bar'
+ let g:linter = {
+ \ 'name': 'x',
+ \ 'lsp': 'socket',
+ \ 'address_callback': 'X',
+ \ 'language_callback': 'x',
+ \ 'project_root_callback': 'x',
+ \ 'lsp_config': {'foo': 'bar'},
\}
+ AssertEqual {'foo': 'bar'}, ale#lsp_linter#GetConfig(0, g:linter)
+
+Execute(PreProcess should accept LSP configuration options via lsp_config as a function):
let g:linter = {
\ 'name': 'x',
\ 'lsp': 'socket',
\ 'address_callback': 'X',
\ 'language_callback': 'x',
\ 'project_root_callback': 'x',
- \ 'lsp_config': g:ale_lsp_configuration,
+ \ 'lsp_config': {-> {'foo': 'bar'}},
\}
- AssertEqual {'foo': 'bar'}, ale#linter#PreProcess('testft', g:linter).lsp_config
+ AssertEqual {'foo': 'bar'}, ale#lsp_linter#GetConfig(0, g:linter)
-Execute(PreProcess should throw when lsp_config is not a Dictionary):
+Execute(PreProcess should throw when lsp_config is not a Dictionary or Function):
AssertThrows call ale#linter#PreProcess('testft', {
\ 'name': 'foo',
\ 'lsp': 'socket',
@@ -567,4 +676,4 @@ Execute(PreProcess should throw when lsp_config is not a Dictionary):
\ 'project_root_callback': 'x',
\ 'lsp_config': 'x',
\})
- AssertEqual '`lsp_config` must be a Dictionary', g:vader_exception
+ AssertEqual '`lsp_config` must be a Dictionary or Function if defined', g:vader_exception