summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/command_callback/dart_paths/.packages0
-rw-r--r--test/command_callback/test_dartanalyzer_command_callback.vader40
-rw-r--r--test/handler/test_dartanalyzer_handler.vader28
3 files changed, 68 insertions, 0 deletions
diff --git a/test/command_callback/dart_paths/.packages b/test/command_callback/dart_paths/.packages
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/dart_paths/.packages
diff --git a/test/command_callback/test_dartanalyzer_command_callback.vader b/test/command_callback/test_dartanalyzer_command_callback.vader
new file mode 100644
index 00000000..c26028de
--- /dev/null
+++ b/test/command_callback/test_dartanalyzer_command_callback.vader
@@ -0,0 +1,40 @@
+Before:
+ Save g:ale_dart_dartanalyzer_executable
+ unlet! g:ale_dart_dartanalyzer_executable
+
+ runtime ale_linters/dart/dartanalyzer.vim
+
+ call ale#test#SetDirectory('/testplugin/test/command_callback')
+
+After:
+ Restore
+
+ call ale#test#RestoreDirectory()
+ call ale#linter#Reset()
+
+Execute(The default command and executable should be correct):
+ AssertEqual
+ \ 'dartanalyzer',
+ \ ale_linters#dart#dartanalyzer#GetExecutable(bufnr(''))
+ AssertEqual
+ \ ale#Escape('dartanalyzer') . ' %t',
+ \ ale_linters#dart#dartanalyzer#GetCommand(bufnr(''))
+
+Execute(The executable should be configurable):
+ let g:ale_dart_dartanalyzer_executable = '/usr/lib/dart/bin/dartanalyzer'
+
+ AssertEqual
+ \ '/usr/lib/dart/bin/dartanalyzer',
+ \ ale_linters#dart#dartanalyzer#GetExecutable(bufnr(''))
+ AssertEqual
+ \ ale#Escape('/usr/lib/dart/bin/dartanalyzer') . ' %t',
+ \ ale_linters#dart#dartanalyzer#GetCommand(bufnr(''))
+
+Execute(The .packages file should be set if detected):
+ call ale#test#SetFilename('dart_paths/foo')
+
+ AssertEqual
+ \ ale#Escape('dartanalyzer')
+ \ . ' --packages ' . ale#Escape(g:dir . '/dart_paths/.packages')
+ \ . ' %t',
+ \ ale_linters#dart#dartanalyzer#GetCommand(bufnr(''))
diff --git a/test/handler/test_dartanalyzer_handler.vader b/test/handler/test_dartanalyzer_handler.vader
new file mode 100644
index 00000000..954850c5
--- /dev/null
+++ b/test/handler/test_dartanalyzer_handler.vader
@@ -0,0 +1,28 @@
+Before:
+ runtime ale_linters/dart/dartanalyzer.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute(Basic problems should be parsed correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'type': 'E',
+ \ 'text': 'expected_token: Expected to find ''}''',
+ \ 'lnum': 5,
+ \ 'col': 1,
+ \ },
+ \ {
+ \ 'type': 'W',
+ \ 'text': 'invalid_assignment: A value of type ''String'' can''t be assigned to a variable of type ''int''',
+ \ 'lnum': 2,
+ \ 'col': 16,
+ \ },
+ \ ],
+ \ ale_linters#dart#dartanalyzer#Handle(bufnr(''), [
+ \ 'Analyzing main.dart...',
+ \ ' error • Expected to find ''}'' at main.dart:5:1 • expected_token',
+ \ ' warning • A value of type ''String'' can''t be assigned to a variable of type ''int'' at main.dart:2:16 • invalid_assignment',
+ \ '1 error and 1 warning found.',
+ \ ])