]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/test_pattern_options.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 '76265755a1add77121c8f9dabb3e9bb70fe9a972' as '.vim/bundle/ale'
[etc/vim.git] / .vim / bundle / ale / test / test_pattern_options.vader
1 Before:
2   Save g:ale_pattern_options
3   Save g:ale_pattern_options_enabled
4   Save b:ale_quitting
5   Save b:ale_original_filetype
6   Save &filetype
7
8   unlet! b:ale_file_changed
9
10   let g:ale_pattern_options_enabled = 1
11   let g:ale_pattern_options = {}
12
13   let b:ale_enabled = 0
14   let b:some_option = 0
15
16   call ale#test#SetDirectory('/testplugin/test')
17
18 After:
19   Restore
20
21   unlet! b:ale_enabled
22   unlet! b:some_option
23
24   call ale#test#RestoreDirectory()
25
26 Execute(The pattern options function should work when there are no patterns):
27   call ale#test#SetFilename('foobar.js')
28   call ale#events#ReadOrEnterEvent(bufnr(''))
29
30 Execute(Buffer variables should be set when filename patterns match):
31   let g:ale_pattern_options = {
32   \ 'baz.*\.js': {
33   \   'ale_enabled': 1,
34   \   'some_option': 347,
35   \   '&filetype': 'pattern_option_set_filetype',
36   \ },
37   \}
38
39   call ale#test#SetFilename('foobar.js')
40   call ale#events#ReadOrEnterEvent(bufnr(''))
41
42   AssertEqual 0, b:ale_enabled
43   AssertEqual 0, b:some_option
44
45   call ale#test#SetFilename('bazboz.js')
46   call ale#events#ReadOrEnterEvent(bufnr(''))
47
48   AssertEqual 1, b:ale_enabled
49   AssertEqual 347, b:some_option
50   AssertEqual 'pattern_option_set_filetype', &filetype
51
52 Execute(Multiple pattern matches should be applied):
53   let g:ale_pattern_options = {
54   \ 'foo': {
55   \   'some_option': 666,
56   \ },
57   \ 'bar': {
58   \   'ale_enabled': 1,
59   \   'some_option': 123,
60   \ },
61   \ 'notmatched': {
62   \   'some_option': 489,
63   \   'ale_enabled': 0,
64   \ },
65   \}
66
67   call ale#test#SetFilename('foobar.js')
68   call ale#events#ReadOrEnterEvent(bufnr(''))
69
70   AssertEqual 1, b:ale_enabled
71   AssertEqual 666, b:some_option
72
73 Execute(Patterns should not be applied when the setting is disabled):
74   let g:ale_pattern_options_enabled = 0
75   let g:ale_pattern_options = {'foo': {'some_option': 666}}
76
77   call ale#test#SetFilename('foobar.js')
78   call ale#events#ReadOrEnterEvent(bufnr(''))
79
80   AssertEqual 0, b:some_option
81
82 " This test is important for making sure we update the sorted items.
83 Execute(Patterns should be applied after the Dictionary changes):
84   call ale#test#SetFilename('foobar.js')
85
86   let g:ale_pattern_options = {}
87
88   call ale#events#ReadOrEnterEvent(bufnr(''))
89
90   AssertEqual 0, b:some_option
91
92   let g:ale_pattern_options['foo'] = {'some_option': 666}
93
94   call ale#events#ReadOrEnterEvent(bufnr(''))
95
96   AssertEqual 666, b:some_option
97
98 Execute(SetOptions should tolerate settings being unset):
99   " This might happen if ALE is loaded in a weird way, so tolerate it.
100   unlet! g:ale_pattern_options
101   unlet! g:ale_pattern_options_enabled
102
103   call ale#events#ReadOrEnterEvent(bufnr(''))
104
105   let g:ale_pattern_options_enabled = 1
106
107   call ale#events#ReadOrEnterEvent(bufnr(''))