summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/command_callback/test_c_clang_tidy_command_callback.vader10
-rw-r--r--test/command_callback/test_cargo_command_callbacks.vader24
-rw-r--r--test/command_callback/test_clang_tidy_command_callback.vader10
-rw-r--r--test/command_callback/test_cpp_clazy_command_callback.vader8
-rw-r--r--test/completion/test_lsp_completion_messages.vader2
-rw-r--r--test/completion/test_lsp_completion_parsing.vader51
-rw-r--r--test/completion/test_tsserver_completion_parsing.vader113
-rw-r--r--test/fixers/test_prettier_standard_callback.vader19
-rw-r--r--test/fixers/test_rubocop_fixer_callback.vader68
-rw-r--r--test/fixers/test_tslint_fixer_callback.vader4
-rw-r--r--test/handler/test_vlog_handler.vader12
-rw-r--r--test/test_hover.vader38
-rw-r--r--test/test_hover_parsing.vader173
-rw-r--r--test/test_path_uri.vader9
-rw-r--r--test/test_writefile_function.vader46
15 files changed, 539 insertions, 48 deletions
diff --git a/test/command_callback/test_c_clang_tidy_command_callback.vader b/test/command_callback/test_c_clang_tidy_command_callback.vader
index 5ebbbd45..c4433550 100644
--- a/test/command_callback/test_c_clang_tidy_command_callback.vader
+++ b/test/command_callback/test_c_clang_tidy_command_callback.vader
@@ -57,7 +57,7 @@ Execute(The build directory setting should override the options):
\ . ' -checks=' . ale#Escape('*') . ' %s'
\ . ' -p ' . ale#Escape('/foo/bar')
-Execute(The build directory should be ignored for header files):
+Execute(The build directory should be used for header files):
call ale#test#SetFilename('test.h')
let b:ale_c_clangtidy_checks = ['*']
@@ -66,12 +66,8 @@ Execute(The build directory should be ignored for header files):
AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy')
- \ . ' -checks=' . ale#Escape('*') . ' %s -- -Wall'
-
- call ale#test#SetFilename('test.h')
-
- AssertLinter 'clang-tidy',
- \ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s -- -Wall'
+ \ . ' -checks=' . ale#Escape('*') . ' %s'
+ \ . ' -p ' . ale#Escape('/foo/bar')
Execute(The executable should be configurable):
let b:ale_c_clangtidy_checks = ['*']
diff --git a/test/command_callback/test_cargo_command_callbacks.vader b/test/command_callback/test_cargo_command_callbacks.vader
index e56551ae..2d83351e 100644
--- a/test/command_callback/test_cargo_command_callbacks.vader
+++ b/test/command_callback/test_cargo_command_callbacks.vader
@@ -169,10 +169,11 @@ Execute(Build supports all cargo flags):
let g:ale_rust_cargo_check_tests = 1
let g:ale_rust_cargo_check_examples = 1
let b:ale_rust_cargo_default_feature_behavior = 'all'
+ let b:ale_rust_cargo_target_dir = 'target/ale'
AssertLinter 'cargo', [
\ ale#Escape('cargo') . ' --version',
- \ 'cargo build --all-targets --examples --tests --frozen --message-format=json -q --all-features',
+ \ 'cargo build --all-targets --examples --tests --target-dir ' . ale#Escape('target/ale') . ' --frozen --message-format=json -q --all-features',
\]
Execute(Clippy supports all cargo flags):
@@ -182,10 +183,11 @@ Execute(Clippy supports all cargo flags):
let g:ale_rust_cargo_check_examples = 1
let b:ale_rust_cargo_default_feature_behavior = 'all'
let b:ale_rust_cargo_clippy_options = '-D warnings'
+ let b:ale_rust_cargo_target_dir = 'target/ale'
AssertLinter 'cargo', [
\ ale#Escape('cargo') . ' --version',
- \ 'cargo clippy --all-targets --examples --tests --frozen --message-format=json -q --all-features -- -D warnings',
+ \ 'cargo clippy --all-targets --examples --tests --target-dir ' . ale#Escape('target/ale') . ' --frozen --message-format=json -q --all-features -- -D warnings',
\]
Execute(cargo-check does not refer ale_rust_cargo_clippy_options):
@@ -197,3 +199,21 @@ Execute(cargo-check does not refer ale_rust_cargo_clippy_options):
\ ale#Escape('cargo') . ' --version',
\ 'cargo check --frozen --message-format=json -q',
\]
+
+Execute(`cargo --target-dir` should be used when the version is new enough and it is set):
+ let b:ale_rust_cargo_target_dir = 'target/ale'
+
+ GivenCommandOutput ['cargo 0.17.0 (3423351a5 2017-10-06)']
+ AssertLinter 'cargo', [
+ \ ale#Escape('cargo') . ' --version',
+ \ 'cargo check --target-dir ' . ale#Escape('target/ale') . g:suffix,
+ \]
+
+Execute(`cargo --target-dir` should not be used when the version is not new enough and it is set):
+ let b:ale_rust_cargo_target_dir = 'target/ale'
+
+ GivenCommandOutput ['cargo 0.16.0 (3423351a5 2017-10-06)']
+ AssertLinter 'cargo', [
+ \ ale#Escape('cargo') . ' --version',
+ \ 'cargo build' . g:suffix,
+ \]
diff --git a/test/command_callback/test_clang_tidy_command_callback.vader b/test/command_callback/test_clang_tidy_command_callback.vader
index c2d18dea..f0a07e8c 100644
--- a/test/command_callback/test_clang_tidy_command_callback.vader
+++ b/test/command_callback/test_clang_tidy_command_callback.vader
@@ -57,7 +57,7 @@ Execute(The build directory setting should override the options):
\ . ' -checks=' . ale#Escape('*') . ' %s'
\ . ' -p ' . ale#Escape('/foo/bar')
-Execute(The build directory should be ignored for header files):
+Execute(The build directory should be used for header files):
call ale#test#SetFilename('test.h')
let b:ale_cpp_clangtidy_checks = ['*']
@@ -66,12 +66,16 @@ Execute(The build directory should be ignored for header files):
AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy')
- \ . ' -checks=' . ale#Escape('*') . ' %s -- -Wall'
+ \ . ' -checks=' . ale#Escape('*') . ' %s'
+ \ . ' -p ' . ale#Escape('/foo/bar')
+ \ . ' -- -x c++'
call ale#test#SetFilename('test.hpp')
AssertLinter 'clang-tidy',
- \ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s -- -Wall'
+ \ ale#Escape('clang-tidy')
+ \ . ' -checks=' . ale#Escape('*') . ' %s'
+ \ . ' -p ' . ale#Escape('/foo/bar')
Execute(The executable should be configurable):
let b:ale_cpp_clangtidy_checks = ['*']
diff --git a/test/command_callback/test_cpp_clazy_command_callback.vader b/test/command_callback/test_cpp_clazy_command_callback.vader
index 1be43b96..e5a81b8f 100644
--- a/test/command_callback/test_cpp_clazy_command_callback.vader
+++ b/test/command_callback/test_cpp_clazy_command_callback.vader
@@ -34,18 +34,20 @@ Execute(The build directory should be configurable):
\ ale#Escape('clazy-standalone')
\ . ' -checks=' . ale#Escape('level1') . ' -p ' . ale#Escape('/foo/bar') . ' %s'
-Execute(The build directory should be ignored for header files):
+Execute(The build directory should be used for header files):
call ale#test#SetFilename('test.h')
let b:ale_c_build_dir = '/foo/bar'
AssertLinter 'clazy-standalone',
- \ ale#Escape('clazy-standalone') . ' -checks=' . ale#Escape('level1') . ' %s'
+ \ ale#Escape('clazy-standalone')
+ \ . ' -checks=' . ale#Escape('level1') . ' -p ' . ale#Escape('/foo/bar') . ' %s'
call ale#test#SetFilename('test.hpp')
AssertLinter 'clazy-standalone',
- \ ale#Escape('clazy-standalone') . ' -checks=' . ale#Escape('level1') . ' %s'
+ \ ale#Escape('clazy-standalone')
+ \ . ' -checks=' . ale#Escape('level1') . ' -p ' . ale#Escape('/foo/bar') . ' %s'
Execute(The executable should be configurable):
let b:ale_cpp_clazy_executable = 'foobar'
diff --git a/test/completion/test_lsp_completion_messages.vader b/test/completion/test_lsp_completion_messages.vader
index 4b7392f5..ee810113 100644
--- a/test/completion/test_lsp_completion_messages.vader
+++ b/test/completion/test_lsp_completion_messages.vader
@@ -121,7 +121,7 @@ Execute(The right message should be sent for the initial tsserver request):
\ 'line': 1,
\ 'offset': 3,
\ 'prefix': 'fo',
- \ 'includeExternalModuleExports': g:ale_completion_tsserver_autoimport,
+ \ 'includeExternalModuleExports': g:ale_completion_autoimport,
\ }]],
\ g:message_list
" We should set up the completion info correctly.
diff --git a/test/completion/test_lsp_completion_parsing.vader b/test/completion/test_lsp_completion_parsing.vader
index e233c955..8b8b41c7 100644
--- a/test/completion/test_lsp_completion_parsing.vader
+++ b/test/completion/test_lsp_completion_parsing.vader
@@ -1,4 +1,12 @@
+Before:
+ Save g:ale_completion_autoimport
+ Save g:ale_completion_max_suggestions
+
+ let g:ale_completion_max_suggestions = 50
+
After:
+ Restore
+
unlet! b:ale_completion_info
Execute(Should handle Rust completion results correctly):
@@ -527,7 +535,9 @@ Execute(Should handle completion messages with the deprecated insertText attribu
\ },
\ })
-Execute(Should handle completion messages with additionalTextEdits):
+Execute(Should handle completion messages with additionalTextEdits when ale_completion_autoimport is turned on):
+ let g:ale_completion_autoimport = 1
+
AssertEqual
\ [
\ {
@@ -596,3 +606,42 @@ Execute(Should handle completion messages with additionalTextEdits):
\ ],
\ },
\ })
+
+Execute(Should not handle completion messages with additionalTextEdits when ale_completion_autoimport is turned off):
+ let g:ale_completion_autoimport = 0
+
+ AssertEqual
+ \ [],
+ \ ale#completion#ParseLSPCompletions({
+ \ 'id': 226,
+ \ 'jsonrpc': '2.0',
+ \ 'result': {
+ \ 'isIncomplete': v:false,
+ \ 'items': [
+ \ {
+ \ 'detail': 'PlayTimeCallback',
+ \ 'filterText': 'next_callback',
+ \ 'insertText': 'next_callback',
+ \ 'insertTextFormat': 1,
+ \ 'kind': 6,
+ \ 'label': ' next_callback',
+ \ 'sortText': '3ee19999next_callback',
+ \ 'additionalTextEdits': [
+ \ {
+ \ 'range': {
+ \ 'start': {
+ \ 'line': 10,
+ \ 'character': 1,
+ \ },
+ \ 'end': {
+ \ 'line': 12,
+ \ 'character': 3,
+ \ },
+ \ },
+ \ 'newText': 'from "module" import next_callback',
+ \ },
+ \ ],
+ \ },
+ \ ],
+ \ },
+ \ })
diff --git a/test/completion/test_tsserver_completion_parsing.vader b/test/completion/test_tsserver_completion_parsing.vader
index 6beb7b0a..aaaaae95 100644
--- a/test/completion/test_tsserver_completion_parsing.vader
+++ b/test/completion/test_tsserver_completion_parsing.vader
@@ -1,4 +1,11 @@
+Before:
+ Save g:ale_completion_tsserver_remove_warnings
+
+ let g:ale_completion_tsserver_remove_warnings = 0
+
After:
+ Restore
+
unlet! b:ale_tsserver_completion_names
Execute(TypeScript completions responses should be parsed correctly):
@@ -29,6 +36,51 @@ Execute(TypeScript completions responses should be parsed correctly):
\ ],
\})
+Execute(TypeScript completions responses should include warnings):
+ AssertEqual
+ \ [
+ \ {
+ \ 'word': 'foo',
+ \ 'source': '/path/to/foo.ts',
+ \ },
+ \ {
+ \ 'word': 'bar',
+ \ 'source': '',
+ \ },
+ \ {
+ \ 'word': 'baz',
+ \ 'source': '',
+ \ }
+ \ ],
+ \ ale#completion#ParseTSServerCompletions({
+ \ 'body': [
+ \ {'name': 'foo', 'source': '/path/to/foo.ts'},
+ \ {'name': 'bar', 'kind': 'warning'},
+ \ {'name': 'baz'},
+ \ ],
+ \})
+
+Execute(TypeScript completions responses should not include warnings if excluded):
+ let g:ale_completion_tsserver_remove_warnings = 1
+ AssertEqual
+ \ [
+ \ {
+ \ 'word': 'foo',
+ \ 'source': '/path/to/foo.ts',
+ \ },
+ \ {
+ \ 'word': 'baz',
+ \ 'source': '',
+ \ }
+ \ ],
+ \ ale#completion#ParseTSServerCompletions({
+ \ 'body': [
+ \ {'name': 'foo', 'source': '/path/to/foo.ts'},
+ \ {'name': 'bar', 'kind': 'warning'},
+ \ {'name': 'baz'},
+ \ ],
+ \})
+
Execute(TypeScript completion details responses should be parsed correctly):
AssertEqual
\ [
@@ -38,7 +90,7 @@ Execute(TypeScript completion details responses should be parsed correctly):
\ 'info': '',
\ 'kind': 'v',
\ 'icase': 1,
- \ 'dup': g:ale_completion_tsserver_autoimport,
+ \ 'dup': g:ale_completion_autoimport,
\ },
\ {
\ 'word': 'def',
@@ -46,7 +98,7 @@ Execute(TypeScript completion details responses should be parsed correctly):
\ 'info': 'foo bar baz',
\ 'kind': 'v',
\ 'icase': 1,
- \ 'dup': g:ale_completion_tsserver_autoimport,
+ \ 'dup': g:ale_completion_autoimport,
\ },
\ {
\ 'word': 'ghi',
@@ -54,7 +106,7 @@ Execute(TypeScript completion details responses should be parsed correctly):
\ 'info': '',
\ 'kind': 'v',
\ 'icase': 1,
- \ 'dup': g:ale_completion_tsserver_autoimport,
+ \ 'dup': g:ale_completion_autoimport,
\ },
\ ],
\ ale#completion#ParseTSServerCompletionEntryDetails({
@@ -132,7 +184,7 @@ Execute(Entries without details should be included in the responses):
\ 'changes': [],
\ }],
\ }),
- \ 'dup': g:ale_completion_tsserver_autoimport,
+ \ 'dup': g:ale_completion_autoimport,
\ },
\ {
\ 'word': 'def',
@@ -140,7 +192,7 @@ Execute(Entries without details should be included in the responses):
\ 'info': 'foo bar baz',
\ 'kind': 'v',
\ 'icase': 1,
- \ 'dup': g:ale_completion_tsserver_autoimport,
+ \ 'dup': g:ale_completion_autoimport,
\ },
\ {
\ 'word': 'xyz',
@@ -197,3 +249,54 @@ Execute(Entries without details should be included in the responses):
\ },
\ ],
\})
+
+Execute(Default imports should be handled correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'word': 'abcd',
+ \ 'menu': 'Import default ''abcd'' from module "./foo" (alias) const abcd: 3',
+ \ 'info': '',
+ \ 'kind': 't',
+ \ 'icase': 1,
+ \ 'user_data': json_encode({
+ \ 'codeActions': [{
+ \ 'description': 'Import default ''abcd'' from module "./foo"',
+ \ 'changes': [],
+ \ }],
+ \ }),
+ \ 'dup': g:ale_completion_autoimport,
+ \ },
+ \ ],
+ \ ale#completion#ParseTSServerCompletionEntryDetails({
+ \ 'body': [
+ \ {
+ \ 'name': 'default',
+ \ 'kind': 'alias',
+ \ 'displayParts': [
+ \ {'kind': 'punctuation', 'text': '('},
+ \ {'kind': 'text', 'text': 'alias'},
+ \ {'kind': 'punctuation', 'text': ')'},
+ \ {'kind': 'space', 'text': ' '},
+ \ {'kind': 'keyword', 'text': 'const'},
+ \ {'kind': 'space', 'text': ' '},
+ \ {'kind': 'localName', 'text': 'abcd'},
+ \ {'kind': 'punctuation', 'text': ':'},
+ \ {'kind': 'space', 'text': ' '},
+ \ {'kind': 'stringLiteral', 'text': '3'},
+ \ {'kind': 'lineBreak', 'text': '^@'},
+ \ {'kind': 'keyword', 'text': 'export'},
+ \ {'kind': 'space', 'text': ' '},
+ \ {'kind': 'keyword', 'text': 'default'},
+ \ {'kind': 'space', 'text': ' '},
+ \ {'kind': 'aliasName', 'text': 'abcd'}
+ \ ],
+ \ 'codeActions': [
+ \ {
+ \ 'description': 'Import default ''abcd'' from module "./foo"',
+ \ 'changes': [],
+ \ },
+ \ ],
+ \ },
+ \ ],
+ \ })
diff --git a/test/fixers/test_prettier_standard_callback.vader b/test/fixers/test_prettier_standard_callback.vader
new file mode 100644
index 00000000..ab33fe20
--- /dev/null
+++ b/test/fixers/test_prettier_standard_callback.vader
@@ -0,0 +1,19 @@
+Before:
+ call ale#assert#SetUpFixerTest('javascript', 'prettier_standard')
+
+ silent cd ..
+ silent cd command_callback
+ let g:dir = getcwd()
+
+After:
+ call ale#assert#TearDownFixerTest()
+
+Execute(The prettier callback should return the correct default values):
+ call ale#test#SetFilename('../prettier-test-files/testfile.js')
+
+ AssertFixer
+ \ {
+ \ 'command': ale#Escape(g:ale_javascript_prettier_standard_executable)
+ \ . ' --stdin'
+ \ . ' --stdin-filepath=%s ',
+ \ }
diff --git a/test/fixers/test_rubocop_fixer_callback.vader b/test/fixers/test_rubocop_fixer_callback.vader
index 866326bf..305881e0 100644
--- a/test/fixers/test_rubocop_fixer_callback.vader
+++ b/test/fixers/test_rubocop_fixer_callback.vader
@@ -21,9 +21,10 @@ Execute(The rubocop callback should return the correct default values):
AssertEqual
\ {
- \ 'read_temporary_file': 1,
+ \ 'process_with': 'ale#fixers#rubocop#PostProcess',
\ 'command': ale#Escape(g:ale_ruby_rubocop_executable)
- \ . ' --auto-correct --force-exclusion %t',
+ \ . ' --auto-correct --force-exclusion --stdin '
+ \ . ale#Escape(expand('#' . bufnr('') . ':p')),
\ },
\ ale#fixers#rubocop#Fix(bufnr(''))
@@ -32,10 +33,11 @@ Execute(The rubocop callback should include configuration files):
AssertEqual
\ {
- \ 'read_temporary_file': 1,
+ \ 'process_with': 'ale#fixers#rubocop#PostProcess',
\ 'command': ale#Escape(g:ale_ruby_rubocop_executable)
\ . ' --config ' . ale#Escape(ale#path#Simplify(g:dir . '/ruby_paths/with_config/.rubocop.yml'))
- \ . ' --auto-correct --force-exclusion %t',
+ \ . ' --auto-correct --force-exclusion --stdin '
+ \ . ale#Escape(expand('#' . bufnr('') . ':p')),
\ },
\ ale#fixers#rubocop#Fix(bufnr(''))
@@ -45,10 +47,64 @@ Execute(The rubocop callback should include custom rubocop options):
AssertEqual
\ {
- \ 'read_temporary_file': 1,
+ \ 'process_with': 'ale#fixers#rubocop#PostProcess',
\ 'command': ale#Escape(g:ale_ruby_rubocop_executable)
\ . ' --config ' . ale#Escape(ale#path#Simplify(g:dir . '/ruby_paths/with_config/.rubocop.yml'))
\ . ' --except Lint/Debugger'
- \ . ' --auto-correct --force-exclusion %t',
+ \ . ' --auto-correct --force-exclusion --stdin '
+ \ . ale#Escape(expand('#' . bufnr('') . ':p')),
\ },
\ ale#fixers#rubocop#Fix(bufnr(''))
+
+Execute(The rubocop callback should use auto-correct-all option when set):
+ let g:ale_ruby_rubocop_auto_correct_all = 1
+ call ale#test#SetFilename('ruby_paths/with_config/dummy.rb')
+
+ AssertEqual
+ \ {
+ \ 'process_with': 'ale#fixers#rubocop#PostProcess',
+ \ 'command': ale#Escape(g:ale_ruby_rubocop_executable)
+ \ . ' --config ' . ale#Escape(ale#path#Simplify(g:dir . '/ruby_paths/with_config/.rubocop.yml'))
+ \ . ' --auto-correct-all --force-exclusion --stdin '
+ \ . ale#Escape(expand('#' . bufnr('') . ':p')),
+ \ },
+ \ ale#fixers#rubocop#Fix(bufnr(''))
+
+Execute(The rubocop post-processor should remove diagnostics content):
+ AssertEqual
+ \ [
+ \ 'class MyModel < ApplicationRecord',
+ \ ' # rubocop:disable Rails/InverseOf',
+ \ ' has_one :something',
+ \ ' # rubocop:enable Rails/InverseOf',
+ \ 'end',
+ \ '',
+ \ 'array = [1, 2, 3,',
+ \ ' 4, 5, 6]',
+ \ 'array = [''run'',',
+ \ ' ''forrest'',',
+ \ ' ''run'']',
+ \ ],
+ \ ale#fixers#rubocop#PostProcess(bufnr(''), [
+ \ 'Inspecting 1 file',
+ \ 'C',
+ \ '',
+ \ 'Offenses:',
+ \ 'app/models/my_model.rb:8:3: C: [Corrected] Layout/ArrayAlignment: ',
+ \ '4, 5, 6]',
+ \ '^',
+ \ '',
+ \ '1 file inspected, 3 offenses detected, 3 offenses corrected',
+ \ '====================',
+ \ 'class MyModel < ApplicationRecord',
+ \ ' # rubocop:disable Rails/InverseOf',
+ \ ' has_one :something',
+ \ ' # rubocop:enable Rails/InverseOf',
+ \ 'end',
+ \ '',
+ \ 'array = [1, 2, 3,',
+ \ ' 4, 5, 6]',
+ \ 'array = [''run'',',
+ \ ' ''forrest'',',
+ \ ' ''run'']',
+ \ ])
diff --git a/test/fixers/test_tslint_fixer_callback.vader b/test/fixers/test_tslint_fixer_callback.vader
index aa9c0322..a88992fa 100644
--- a/test/fixers/test_tslint_fixer_callback.vader
+++ b/test/fixers/test_tslint_fixer_callback.vader
@@ -27,7 +27,7 @@ Execute(The tslint callback should return the correct default values):
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('tslint')
\ . ' -c ' . ale#Escape('tslint.json')
- \ . ' --fix %t',
+ \ . ' --outputAbsolutePaths --fix %t',
\ },
\ ale#fixers#tslint#Fix(bufnr(''))
@@ -40,6 +40,6 @@ Execute(The tslint callback should include custom tslint config option):
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('tslint')
\ . ' -c ' . ale#Escape('.tslintrc')
- \ . ' --fix %t',
+ \ . ' --outputAbsolutePaths --fix %t',
\ },
\ ale#fixers#tslint#Fix(bufnr(''))
diff --git a/test/handler/test_vlog_handler.vader b/test/handler/test_vlog_handler.vader
index daf3cdcf..7262f63d 100644
--- a/test/handler/test_vlog_handler.vader
+++ b/test/handler/test_vlog_handler.vader
@@ -10,12 +10,14 @@ Execute(The vlog handler should parse old-style lines correctly):
\ {
\ 'lnum': 7,
\ 'type': 'W',
- \ 'text': '(vlog-2623) Undefined variable: C.'
+ \ 'text': '(vlog-2623) Undefined variable: C.',
+ \ 'filename': 'add.v'
\ },
\ {
\ 'lnum': 1,
\ 'type': 'E',
- \ 'text': '(vlog-13294) Identifier must be declared with a port mode: C.'
+ \ 'text': '(vlog-13294) Identifier must be declared with a port mode: C.',
+ \ 'filename': 'file.v'
\ },
\ ],
\ ale_linters#verilog#vlog#Handle(bufnr(''), [
@@ -29,12 +31,14 @@ Execute(The vlog handler should parse new-style lines correctly):
\ {
\ 'lnum': 7,
\ 'type': 'W',
- \ 'text': '(vlog-2623) Undefined variable: C.'
+ \ 'text': '(vlog-2623) Undefined variable: C.',
+ \ 'filename': 'add.v'
\ },
\ {
\ 'lnum': 1,
\ 'type': 'E',
- \ 'text': '(vlog-13294) Identifier must be declared with a port mode: C.'
+ \ 'text': '(vlog-13294) Identifier must be declared with a port mode: C.',
+ \ 'filename': 'file.v'
\ },
\ ],
\ ale_linters#verilog#vlog#Handle(bufnr(''), [
diff --git a/test/test_hover.vader b/test/test_hover.vader
index 8b4cf7bd..9689cda2 100644
--- a/test/test_hover.vader
+++ b/test/test_hover.vader
@@ -5,7 +5,7 @@ Before:
let g:Callback = 0
let g:message_list = []
let g:item_list = []
- let g:echo_list = []
+ let g:show_message_arg_list = []
runtime autoload/ale/linter.vim
runtime autoload/ale/lsp.vim
@@ -27,8 +27,8 @@ Before:
return 42
endfunction
- function! ale#util#ShowMessage(string) abort
- call add(g:echo_list, a:string)
+ function! ale#util#ShowMessage(string, ...) abort
+ call add(g:show_message_arg_list, [a:string] + a:000)
endfunction
function! HandleValidLSPResult(result) abort
@@ -58,7 +58,7 @@ After:
unlet! g:Callback
unlet! g:message_list
unlet! b:ale_linters
- unlet! g:echo_list
+ unlet! g:show_message_arg_list
delfunction HandleValidLSPResult
@@ -112,31 +112,31 @@ Execute(tsserver quickinfo displayString values should be displayed):
\ }
\)
- AssertEqual ['foo bar'], g:echo_list
+ AssertEqual [['foo bar']], g:show_message_arg_list
AssertEqual {}, ale#hover#GetMap()
Execute(LSP hover responses with just a string should be handled):
call HandleValidLSPResult({'contents': 'foobar'})
- AssertEqual ['foobar'], g:echo_list
+ AssertEqual [['foobar', {'commands': []}]], g:show_message_arg_list
AssertEqual {}, ale#hover#GetMap()
Execute(LSP hover null responses should be handled):
call HandleValidLSPResult(v:null)
- AssertEqual [], g:echo_list
+ AssertEqual [], g:show_message_arg_list
AssertEqual {}, ale#hover#GetMap()
Execute(LSP hover responses with markup content should be handled):
- call HandleValidLSPResult({'contents': {'kind': 'something', 'value': 'markup'}})
+ call HandleValidLSPResult({'contents': {'kind': 'markdown', 'value': 'markup'}})
- AssertEqual ['markup'], g:echo_list
+ AssertEqual [['markup', {'commands': []}]], g:show_message_arg_list
AssertEqual {}, ale#hover#GetMap()
Execute(LSP hover responses with markup content missing values should be handled):
- call HandleValidLSPResult({'contents': {'kind': 'something'}})
+ call HandleValidLSPResult({'contents': {'kind': 'markdown'}})
- AssertEqual [], g:echo_list
+ AssertEqual [], g:show_message_arg_list
AssertEqual {}, ale#hover#GetMap()
Execute(LSP hover response with lists of strings should be handled):
@@ -145,17 +145,27 @@ Execute(LSP hover response with lists of strings should be handled):
\ "bar\n",
\]})
- AssertEqual ["foo\n\nbar\n"], g:echo_list
+ AssertEqual [["foo\n\nbar", {'commands': []}]], g:show_message_arg_list
AssertEqual {}, ale#hover#GetMap()
Execute(LSP hover response with lists of strings and marked strings should be handled):
call HandleValidLSPResult({'contents': [
\ {'language': 'rust', 'value': 'foo'},
- \ {'language': 'foobar'},
\ "bar\n",
\]})
- AssertEqual ["foo\nbar\n"], g:echo_list
+ AssertEqual [
+ \ [
+ \ "foo\n\nbar",
+ \ {
+ \ 'commands': [
+ \ 'unlet! b:current_syntax',
+ \ 'syntax include @ALE_hover_rust syntax/rust.vim',
+ \ 'syntax region ALE_hover_1 start=/\%1l/ end=/\%2l/ contains=@ALE_hover_rust',
+ \ ],
+ \ },
+ \ ],
+ \], g:show_message_arg_list
AssertEqual {}, ale#hover#GetMap()
Execute(tsserver responses for documentation requests should be handled):
diff --git a/test/test_hover_parsing.vader b/test/test_hover_parsing.vader
new file mode 100644
index 00000000..4129c26a
--- /dev/null
+++ b/test/test_hover_parsing.vader
@@ -0,0 +1,173 @@
+Execute(Invalid results should be handled):
+ AssertEqual [[], []], ale#hover#ParseLSPResult(0)
+ AssertEqual [[], []], ale#hover#ParseLSPResult([0])
+ AssertEqual [[], []], ale#hover#ParseLSPResult('')
+ AssertEqual [[], []], ale#hover#ParseLSPResult({})
+ AssertEqual [[], []], ale#hover#ParseLSPResult([{}])
+ AssertEqual [[], []], ale#hover#ParseLSPResult([''])
+ AssertEqual [[], []], ale#hover#ParseLSPResult({'value': ''})
+ AssertEqual [[], []], ale#hover#ParseLSPResult([{'value': ''}])
+ AssertEqual [[], []], ale#hover#ParseLSPResult({'kind': 'markdown'})
+ AssertEqual [[], []], ale#hover#ParseLSPResult({'kind': 'plaintext'})
+ AssertEqual [[], []], ale#hover#ParseLSPResult({'kind': 'x', 'value': 'xxx'})
+
+Execute(A string with a code fence should be handled):
+ AssertEqual
+ \ [
+ \ [
+ \ 'unlet! b:current_syntax',
+ \ 'syntax include @ALE_hover_python syntax/python.vim',
+ \ 'syntax region ALE_hover_1 start=/\%1l/ end=/\%3l/ contains=@ALE_hover_python',
+ \ ],
+ \ [
+ \ 'def foo():',
+ \ ' pass',
+ \ ],
+ \ ],
+ \ ale#hover#ParseLSPResult(join([
+ \ '```python',
+ \ 'def foo():',
+ \ ' pass',
+ \ '```',
+ \ ], "\n"))
+
+ AssertEqual
+ \ [
+ \ [
+ \ 'unlet! b:current_syntax',
+ \ 'syntax include @ALE_hover_python syntax/python.vim',
+ \ 'unlet! b:current_syntax',
+ \ 'syntax include @ALE_hover_typescript syntax/typescript.vim',
+ \ 'syntax region ALE_hover_1 start=/\%1l/ end=/\%3l/ contains=@ALE_hover_python',
+ \ 'syntax region ALE_hover_2 start=/\%5l/ end=/\%8l/ contains=@ALE_hover_python',
+ \ 'syntax region ALE_hover_3 start=/\%8l/ end=/\%10l/ contains=@ALE_hover_typescript',
+ \ ],
+ \ [
+ \ 'def foo():',
+ \ ' pass',
+ \ '',
+ \ 'middle line',
+ \ '',
+ \ 'def bar():',
+ \ ' pass',
+ \ '',
+ \ 'const baz = () => undefined',
+ \ ],
+ \ ],
+ \ ale#hover#ParseLSPResult(join([
+ \ '```python',
+ \ 'def foo():',
+ \ ' pass',
+ \ '```',
+ \ 'middle line',
+ \ '```python',
+ \ 'def bar():',
+ \ ' pass',
+ \ '```',
+ \ '```typescript',
+ \ 'const baz = () => undefined',
+ \ '```',
+ \ ], "\n"))
+
+Execute(Multiple strings with fences should be handled):
+ AssertEqual
+ \ [
+ \ [
+ \ 'unlet! b:current_syntax',
+ \ 'syntax include @ALE_hover_python syntax/python.vim',
+ \ 'unlet! b:current_syntax',
+ \ 'syntax include @ALE_hover_typescript syntax/typescript.vim',
+ \ 'syntax region ALE_hover_1 start=/\%1l/ end=/\%3l/ contains=@ALE_hover_python',
+ \ 'syntax region ALE_hover_2 start=/\%5l/ end=/\%8l/ contains=@ALE_hover_python',
+ \ 'syntax region ALE_hover_3 start=/\%8l/ end=/\%10l/ contains=@ALE_hover_typescript',
+ \ ],
+ \ [
+ \ 'def foo():',
+ \ ' pass',
+ \ '',
+ \ 'middle line',
+ \ '',
+ \ 'def bar():',
+ \ ' pass',
+ \ '',
+ \ 'const baz = () => undefined',
+ \ ],
+ \ ],
+ \ ale#hover#ParseLSPResult([
+ \ join([
+ \ '```python',
+ \ 'def foo():',
+ \ ' pass',
+ \ '```',
+ \ ], "\n"),
+ \ join([
+ \ 'middle line',
+ \ '```python',
+ \ 'def bar():',
+ \ ' pass',
+ \ '```',
+ \ '```typescript',
+ \ 'const baz = () => undefined',
+ \ '```',
+ \ ], "\n"),
+ \ ])
+
+Execute(Objects with kinds should be handled):
+ AssertEqual
+ \ [
+ \ [
+ \ 'unlet! b:current_syntax',
+ \ 'syntax include @ALE_hover_python syntax/python.vim',
+ \ 'syntax region ALE_hover_1 start=/\%1l/ end=/\%3l/ contains=@ALE_hover_python',
+ \ ],
+ \ [
+ \ 'def foo():',
+ \ ' pass',
+ \ '',
+ \ '```typescript',
+ \ 'const baz = () => undefined',
+ \ '```',
+ \ ],
+ \ ],
+ \ ale#hover#ParseLSPResult([
+ \ {
+ \ 'kind': 'markdown',
+ \ 'value': join([
+ \ '```python',
+ \ 'def foo():',
+ \ ' pass',
+ \ '```',
+ \ ], "\n"),
+ \ },
+ \ {
+ \ 'kind': 'plaintext',
+ \ 'value': join([
+ \ '```typescript',
+ \ 'const baz = () => undefined',
+ \ '```',
+ \ ], "\n"),
+ \ },
+ \ ])
+
+Execute(Simple markdown formatting should be handled):
+ AssertEqual
+ \ [
+ \ [
+ \ 'unlet! b:current_syntax',
+ \ 'syntax include @ALE_hover_python syntax/python.vim',
+ \ 'syntax region ALE_hover_1 start=/\%1l/ end=/\%3l/ contains=@ALE_hover_python',
+ \ ],
+ \ [
+ \ 'def foo():',
+ \ ' pass',
+ \ '',
+ \ 'formatted _ line _',
+ \ ],
+ \ ],
+ \ ale#hover#ParseLSPResult(join([
+ \ '```python',
+ \ 'def foo():',
+ \ ' pass',
+ \ '```',
+ \ 'formatted \_ line \_',
+ \ ], "\n"))
diff --git a/test/test_path_uri.vader b/test/test_path_uri.vader
index cc2287cb..0f2cba7e 100644
--- a/test/test_path_uri.vader
+++ b/test/test_path_uri.vader
@@ -1,3 +1,6 @@
+Before:
+ scriptencoding utf-8
+
Execute(ale#path#ToURI should work for Windows paths):
AssertEqual 'file:///C:/foo/bar/baz.tst', ale#path#ToURI('C:\foo\bar\baz.tst')
AssertEqual 'foo/bar/baz.tst', ale#path#ToURI('foo\bar\baz.tst')
@@ -62,3 +65,9 @@ Execute(ale#path#ToURI should percent encode unsafe characters):
Execute(ale#path#FromURI should decode percent encodings):
AssertEqual ' +:?&=', ale#path#FromURI('%20%2b%3a%3f%26%3d')
+
+Execute(ale#path#ToURI should handle UTF-8):
+ AssertEqual 'file:///T%c3%a9l%c3%a9chargement', ale#path#ToURI('/Téléchargement')
+
+Execute(ale#path#FromURI should handle UTF-8):
+ AssertEqual '/Téléchargement', ale#path#FromURI('file:///T%C3%A9l%C3%A9chargement')
diff --git a/test/test_writefile_function.vader b/test/test_writefile_function.vader
index 811d59e8..53a88331 100644
--- a/test/test_writefile_function.vader
+++ b/test/test_writefile_function.vader
@@ -69,3 +69,49 @@ Execute(Unix file lines should be written as normal):
AssertEqual
\ ['first', 'second', 'third', ''],
\ readfile(g:new_line_test_file, 'b')
+
+Execute(Newline at end of file should be preserved even when nofixeol):
+ call ale#test#SetFilename(g:new_line_test_file)
+
+ setlocal buftype=
+ noautocmd :w
+ noautocmd :e! ++ff=unix
+ set eol
+ set nofixeol
+
+ call ale#util#Writefile(bufnr(''), getline(1, '$'), g:new_line_test_file)
+
+ AssertEqual
+ \ ['first', 'second', 'third', ''],
+ \ readfile(g:new_line_test_file, 'b')
+
+Execute(Newline should not be appended on write when noeol and nofixeol):
+ call ale#test#SetFilename(g:new_line_test_file)
+
+ setlocal buftype=
+ noautocmd :w
+ noautocmd :e! ++ff=unix
+ set noeol
+ set nofixeol
+
+ call ale#util#Writefile(bufnr(''), getline(1, '$'), g:new_line_test_file)
+
+ AssertEqual
+ \ ['first', 'second', 'third'],
+ \ readfile(g:new_line_test_file, 'b')
+
+Execute(Newline should be appended on write when noeol and fixeol):
+ call ale#test#SetFilename(g:new_line_test_file)
+
+ setlocal buftype=
+ noautocmd :w
+ noautocmd :e! ++ff=unix
+ set noeol
+ set fixeol
+
+ call ale#util#Writefile(bufnr(''), getline(1, '$'), g:new_line_test_file)
+
+ AssertEqual
+ \ ['first', 'second', 'third', ''],
+ \ readfile(g:new_line_test_file, 'b')
+