summaryrefslogtreecommitdiff
path: root/test/fixers
diff options
context:
space:
mode:
authorrhysd <lin90162@yahoo.co.jp>2018-09-18 15:41:33 +0900
committerrhysd <lin90162@yahoo.co.jp>2018-09-18 17:51:00 +0900
commit532686102ef3bdf00b00340964d2dfe4bb7f875e (patch)
treebf181ab52a5cfd0558e4339c8ca0ce2bc379a48d /test/fixers
parentddb3e6d57acfc9081f8c6846d896542014e3024b (diff)
downloadale-532686102ef3bdf00b00340964d2dfe4bb7f875e.zip
shfmt: Use Vim's indent config as default indent width
Diffstat (limited to 'test/fixers')
-rw-r--r--test/fixers/test_shfmt_fixer_callback.vader37
1 files changed, 36 insertions, 1 deletions
diff --git a/test/fixers/test_shfmt_fixer_callback.vader b/test/fixers/test_shfmt_fixer_callback.vader
index 5dc6e863..99cb0987 100644
--- a/test/fixers/test_shfmt_fixer_callback.vader
+++ b/test/fixers/test_shfmt_fixer_callback.vader
@@ -1,17 +1,52 @@
Before:
Save g:ale_sh_shfmt_executable
Save g:ale_sh_shfmt_options
+ Save &l:expandtab
+ Save &l:shiftwidth
+ Save &l:tabstop
After:
Restore
-Execute(The shfmt callback should return the correct default values):
+Execute(The shfmt callback should return 'shfmt' as default command):
+ setlocal noexpandtab
+ Assert
+ \ ale#fixers#shfmt#Fix(bufnr('')).command =~# '^' . ale#Escape('shfmt'),
+ \ "Default command name is expected to be 'shfmt'"
+
+Execute(The shfmt callback should return the command with no option as default when noexpandtab is set):
+ let g:ale_sh_shfmt_executable = 'shfmt'
+ let g:ale_sh_shfmt_options = ''
+ setlocal noexpandtab
AssertEqual
\ {
\ 'command': ale#Escape('shfmt'),
\ },
\ ale#fixers#shfmt#Fix(bufnr(''))
+Execute(The shfmt callback should return the command specifying indent width by looking shiftwidth as default):
+ let g:ale_sh_shfmt_executable = 'shfmt'
+ let g:ale_sh_shfmt_options = ''
+ setlocal expandtab
+ setlocal shiftwidth=4
+ AssertEqual
+ \ {
+ \ 'command': ale#Escape('shfmt') . ' -i 4',
+ \ },
+ \ ale#fixers#shfmt#Fix(bufnr(''))
+
+Execute(The shfmt callback should return the command specifying indent width by looking tabstop when shiftwidth is 0 as default):
+ let g:ale_sh_shfmt_executable = 'shfmt'
+ let g:ale_sh_shfmt_options = ''
+ setlocal expandtab
+ setlocal shiftwidth=0
+ setlocal tabstop=8
+ AssertEqual
+ \ {
+ \ 'command': ale#Escape('shfmt') . ' -i 8',
+ \ },
+ \ ale#fixers#shfmt#Fix(bufnr(''))
+
Execute(The shfmt executable and options should be configurable):
let g:ale_sh_shfmt_executable = 'foobar'
let g:ale_sh_shfmt_options = '--some-option'