]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/fix/test_ale_fix_ignore.vader

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '294584081929424aec883f90c7d6515b3743358d' as '.vim/bundle/vim-lsp-ale'
[etc/vim.git] / .vim / bundle / ale / test / fix / test_ale_fix_ignore.vader
1 Before:
2   Save g:ale_fixers
3   Save g:ale_fix_on_save
4   Save g:ale_fix_on_save_ignore
5
6   let g:ale_fix_on_save = 1
7   let g:ale_fixers = {'abc': ['a', 'b'], 'xyz': ['c', 'd']}
8   unlet! b:ale_fixers
9   unlet! b:ale_fix_on_save_ignore
10
11   function FixerA(buffer, lines) abort
12     return a:lines + ['a']
13   endfunction
14
15   function FixerB(buffer, lines) abort
16     return a:lines + ['b']
17   endfunction
18
19   function FixerC(buffer, lines) abort
20     return a:lines + ['c']
21   endfunction
22
23   function FixerD(buffer, lines) abort
24     return a:lines + ['d']
25   endfunction
26
27   set filetype=abc.xyz
28   let g:test_filename = tempname()
29   execute 'noautocmd silent file ' . fnameescape(g:test_filename)
30
31   call ale#fix#registry#Add('a', 'FixerA', ['abc'], '')
32   call ale#fix#registry#Add('b', 'FixerB', ['abc'], '')
33   call ale#fix#registry#Add('c', 'FixerC', ['xyz'], '')
34   call ale#fix#registry#Add('d', 'FixerD', ['xyz'], '')
35
36 After:
37   Restore
38
39   if exists('g:test_filename') && filereadable(g:test_filename)
40     call delete(g:test_filename)
41   endif
42
43   unlet! b:ale_fixers
44   unlet! b:ale_fix_on_save_ignore
45   unlet! g:test_filename
46
47   delfunction FixerA
48   delfunction FixerB
49   delfunction FixerC
50   delfunction FixerD
51
52   call ale#fix#registry#ResetToDefaults()
53
54 Given abc.xyz (An empty file):
55 Execute(Ignoring with a filetype in a global Dictionary should work):
56   let g:ale_fix_on_save_ignore = {'abc': ['b'], 'xyz': ['c']}
57
58   call ale#events#SaveEvent(bufnr(''))
59
60   AssertEqual ['', 'a', 'd'], getline(1, '$')
61
62 Execute(Ignoring with a filetype in a global List should work):
63   let g:ale_fix_on_save_ignore = ['b', 'c']
64
65   call ale#events#SaveEvent(bufnr(''))
66
67   AssertEqual ['', 'a', 'd'], getline(1, '$')
68
69 Execute(Ignoring with a filetype in a local Dictionary should work):
70   let g:ale_fix_on_save_ignore = {'abc': ['b'], 'xyz': ['c']}
71   " The local Dictionary should entirely replace the global one.
72   let b:ale_fix_on_save_ignore = {'abc': ['b']}
73
74   call ale#events#SaveEvent(bufnr(''))
75
76   AssertEqual ['', 'a', 'c', 'd'], getline(1, '$')
77
78 Execute(Ignoring with a filetype in a local List should work):
79   let g:ale_fix_on_save_ignore = {'abc': ['b'], 'xyz': ['c']}
80   " The local List should entirely replace the global Dictionary.
81   let b:ale_fix_on_save_ignore = ['b']
82
83   call ale#events#SaveEvent(bufnr(''))
84
85   AssertEqual ['', 'a', 'c', 'd'], getline(1, '$')
86
87 Execute(Ignoring functions by reference with a Dictionary should work):
88   let g:ale_fixers = {
89   \ 'abc': [function('FixerA'), function('FixerB')],
90   \ 'xyz': [function('FixerC'), function('FixerD')],
91   \}
92   let b:ale_fix_on_save_ignore = {
93   \ 'abc': [function('FixerB')],
94   \ 'xyz': [function('FixerC')],
95   \}
96
97   call ale#events#SaveEvent(bufnr(''))
98
99   AssertEqual ['', 'a', 'd'], getline(1, '$')
100
101 Execute(Ignoring functions by reference with a List should work):
102   let g:ale_fixers = {
103   \ 'abc': [function('FixerA'), function('FixerB')],
104   \ 'xyz': [function('FixerC'), function('FixerD')],
105   \}
106   let b:ale_fix_on_save_ignore = [function('FixerB'), function('FixerC')]
107
108   call ale#events#SaveEvent(bufnr(''))
109
110   AssertEqual ['', 'a', 'd'], getline(1, '$')