summaryrefslogtreecommitdiff
path: root/test/test_pattern_options.vader
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-11-11 13:44:05 +0000
committerw0rp <devw0rp@gmail.com>2017-11-12 10:56:53 +0000
commit8cd1ccff844bb8a23a616c09cf55a9f40018e41f (patch)
tree6cd53a91450a70ca8658bd963bc3057984d20cea /test/test_pattern_options.vader
parent6c60ca24c13872c8e2e1e56154eac56e8555452c (diff)
downloadale-8cd1ccff844bb8a23a616c09cf55a9f40018e41f.zip
#1095 Apply all patterns for g:ale_pattern_options, instead of just the first match
Diffstat (limited to 'test/test_pattern_options.vader')
-rw-r--r--test/test_pattern_options.vader68
1 files changed, 56 insertions, 12 deletions
diff --git a/test/test_pattern_options.vader b/test/test_pattern_options.vader
index 164e5aa7..0ad4415f 100644
--- a/test/test_pattern_options.vader
+++ b/test/test_pattern_options.vader
@@ -3,30 +3,74 @@ Before:
Save g:ale_pattern_options_enabled
Save &filetype
+ let g:ale_pattern_options_enabled = 1
+ let g:ale_pattern_options = {}
+
+ let b:ale_enabled = 0
+ let b:some_option = 0
+
+ call ale#test#SetDirectory('/testplugin/test')
+
After:
Restore
unlet! b:ale_enabled
unlet! b:some_option
-Execute(Buffer variables should be set when filename patterns match):
- let g:ale_pattern_options = {'baz.*\.js': {
- \ 'ale_enabled': 1,
- \ 'some_option': 347,
- \ '&filetype': 'pattern_option_set_filetype',
- \}}
+ call ale#test#RestoreDirectory()
- silent! file foobar.js
+Execute(The pattern options function should work when there are no patterns):
+ call ale#test#SetFilename('foobar.js')
+ call ale#pattern_options#SetOptions(bufnr(''))
- call ale#pattern_options#SetOptions()
+Execute(Buffer variables should be set when filename patterns match):
+ let g:ale_pattern_options = {
+ \ 'baz.*\.js': {
+ \ 'ale_enabled': 1,
+ \ 'some_option': 347,
+ \ '&filetype': 'pattern_option_set_filetype',
+ \ },
+ \}
- Assert !exists('b:ale_enabled')
- Assert !exists('b:some_option')
+ call ale#test#SetFilename('foobar.js')
+ call ale#pattern_options#SetOptions(bufnr(''))
- silent! file bazboz.js
+ AssertEqual 0, b:ale_enabled
+ AssertEqual 0, b:some_option
- call ale#pattern_options#SetOptions()
+ call ale#test#SetFilename('bazboz.js')
+ call ale#pattern_options#SetOptions(bufnr(''))
AssertEqual 1, b:ale_enabled
AssertEqual 347, b:some_option
AssertEqual 'pattern_option_set_filetype', &filetype
+
+Execute(Multiple pattern matches should be applied):
+ let g:ale_pattern_options = {
+ \ 'foo': {
+ \ 'some_option': 666,
+ \ },
+ \ 'bar': {
+ \ 'ale_enabled': 1,
+ \ 'some_option': 123,
+ \ },
+ \ 'notmatched': {
+ \ 'some_option': 489,
+ \ 'ale_enabled': 0,
+ \ },
+ \}
+
+ call ale#test#SetFilename('foobar.js')
+ call ale#pattern_options#SetOptions(bufnr(''))
+
+ AssertEqual 1, b:ale_enabled
+ AssertEqual 666, b:some_option
+
+Execute(Patterns should not be applied when the setting is disabled):
+ let g:ale_pattern_options_enabled = 0
+ let g:ale_pattern_options = {'foo': {'some_option': 666}}
+
+ call ale#test#SetFilename('foobar.js')
+ call ale#pattern_options#SetOptions(bufnr(''))
+
+ AssertEqual 0, b:some_option