summaryrefslogtreecommitdiff
path: root/test/handler/test_luacheck_handler.vader
diff options
context:
space:
mode:
authorjiangzhi.xie <xiejiangzhi@gmail.com>2018-01-08 23:19:17 +0800
committerjiangzhi.xie <xiejiangzhi@gmail.com>2018-01-08 23:32:02 +0800
commit112fcf7dd57a077f70ae39bb03d192f5c832aa2e (patch)
tree7f869ba3afaec822893b7e0a2856877a05153158 /test/handler/test_luacheck_handler.vader
parentf1747901cc00abb7becb64c02bfccad46b66ed21 (diff)
downloadale-112fcf7dd57a077f70ae39bb03d192f5c832aa2e.zip
Add a luac linter for Lua
Diffstat (limited to 'test/handler/test_luacheck_handler.vader')
-rw-r--r--test/handler/test_luacheck_handler.vader62
1 files changed, 62 insertions, 0 deletions
diff --git a/test/handler/test_luacheck_handler.vader b/test/handler/test_luacheck_handler.vader
new file mode 100644
index 00000000..7cebb017
--- /dev/null
+++ b/test/handler/test_luacheck_handler.vader
@@ -0,0 +1,62 @@
+Before:
+ Save g:ale_warn_about_trailing_whitespace
+
+ let g:ale_warn_about_trailing_whitespace = 1
+
+ runtime ale_linters/lua/luacheck.vim
+
+After:
+ Restore
+ call ale#linter#Reset()
+
+Execute(The luacheck handler should parse lines correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 1,
+ \ 'col': 8,
+ \ 'text': 'line contains trailing whitespace',
+ \ 'code': 'W612',
+ \ 'type': 'W',
+ \ },
+ \ {
+ \ 'lnum': 3,
+ \ 'col': 5,
+ \ 'text': 'unused loop variable ''k''',
+ \ 'code': 'W213',
+ \ 'type': 'W',
+ \ },
+ \ {
+ \ 'lnum': 3,
+ \ 'col': 19,
+ \ 'text': 'accessing undefined variable ''x''',
+ \ 'code': 'W113',
+ \ 'type': 'W',
+ \ },
+ \ ],
+ \ ale_linters#lua#luacheck#Handle(347, [
+ \ ' /file/path/here.lua:1:8: (W612) line contains trailing whitespace',
+ \ ' /file/path/here.lua:3:5: (W213) unused loop variable ''k''',
+ \ ' /file/path/here.lua:3:19: (W113) accessing undefined variable ''x''',
+ \ ])
+
+Execute(The luacheck handler should respect the warn_about_trailing_whitespace option):
+ let g:ale_warn_about_trailing_whitespace = 0
+
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 5,
+ \ 'col': 43,
+ \ 'text': 'unused argument ''g''',
+ \ 'code': 'W212',
+ \ 'type': 'W',
+ \ }
+ \ ],
+ \ ale_linters#lua#luacheck#Handle(347, [
+ \ '/file/path/here.lua:15:97: (W614) trailing whitespace in a comment',
+ \ '/file/path/here.lua:16:60: (W612) line contains trailing whitespace',
+ \ '/file/path/here.lua:17:1: (W611) line contains only whitespace',
+ \ '/file/path/here.lua:27:57: (W613) trailing whitespace in a string',
+ \ '/file/path/here.lua:5:43: (W212) unused argument ''g''',
+ \ ])