-
Notifications
You must be signed in to change notification settings - Fork 189
/
autocomplete_test.vim
64 lines (51 loc) · 1.38 KB
/
autocomplete_test.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
let s:tests = {}
" Utilities
function! s:Run(function)
let o = &filetype
" let output = call(a:function, [''])
" call function(a:function)
let output = call(a:function, [])
let &filetype = o
" expecting output to either be a 1 or 0
let s:tests[a:function[2:]] = output
return output
endfunction
function! s:Cleanup()
let error = 0
for test in keys(s:tests)
if !s:tests[test]
let error = 1
endif
echom test . ' : ' . s:tests[test]
endfor
if error
" make vim exit with a non-zero value
cquit!
else
qall!
endif
endfunction
" Test Definitions
function! s:valid_option()
let &filetype = 'python'
let g:neoformat_python_enabled = ['autopep8', 'yapf']
let out = neoformat#CompleteFormatters('auto','', 0)
return ['autopep8'] == out
endfunction
function! s:invalid_option()
let &filetype = 'javascript'
let g:neoformat_python_enabled = ['autopep8']
let out = neoformat#CompleteFormatters('autopep8', '', 0)
return [] == out
endfunction
function! s:multi_options()
let &filetype = 'python'
let g:neoformat_python_enabled = ['autopep8', 'yapf']
let out = neoformat#CompleteFormatters('autopep8', '', 0)
return [] == out
endfunction
" Run Tests
call s:Run('s:valid_option')
call s:Run('s:invalid_option')
" Check the outputs
call s:Cleanup()