]> git.madduck.net Git - etc/vim.git/blobdiff - .vim/bundle/ale/test/test_should_do_nothing_conditions.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_should_do_nothing_conditions.vader
diff --git a/.vim/bundle/ale/test/test_should_do_nothing_conditions.vader b/.vim/bundle/ale/test/test_should_do_nothing_conditions.vader
new file mode 100644 (file)
index 0000000..6dfed55
--- /dev/null
@@ -0,0 +1,88 @@
+Before:
+  Save g:ale_filetype_blacklist
+  Save g:ale_maximum_file_size
+  Save g:ale_enabled
+  Save &l:statusline
+
+  let b:fake_mode = 'n'
+
+  call ale#test#SetDirectory('/testplugin/test')
+
+  let b:funky_command_created = 0
+
+  runtime autoload/ale/util.vim
+
+  function! ale#util#Mode(...) abort
+    return b:fake_mode
+  endfunction
+
+  " We will test for the existence of this command, so create one if needed.
+  if !exists(':CtrlPFunky')
+    command CtrlPFunky echo
+    let b:funky_command_created = 1
+  endif
+
+After:
+  Restore
+
+  call ale#test#RestoreDirectory()
+
+  if b:funky_command_created
+    delcommand CtrlPFunky
+    let b:funky_command_created = 0
+  endif
+
+  unlet! b:funky_command_created
+  unlet! b:fake_mode
+
+  if &diff is 1
+    let &diff = 0
+  endif
+
+  runtime autoload/ale/util.vim
+
+Given foobar(An empty file):
+Execute(ALE shouldn't do much of anything for ctrlp-funky buffers):
+  Assert !ale#ShouldDoNothing(bufnr('')), 'The preliminary check failed'
+
+  let &l:statusline = '%#CtrlPMode2# prt %*%#CtrlPMode1# line %* <mru>={%#CtrlPMode1# funky %*}=<fil> <-> %=%<%#CtrlPMode2# %{getcwd()} %*'
+
+  Assert ale#ShouldDoNothing(bufnr(''))
+
+Execute(ALE shouldn't try to check buffers with '.' as the filename):
+  AssertEqual
+  \ 0,
+  \ ale#ShouldDoNothing(bufnr('')),
+  \ 'ShouldDoNothing() was 1 for some other reason'
+
+  silent! noautocmd file .
+
+  Assert ale#ShouldDoNothing(bufnr(''))
+
+Execute(DoNothing should return 1 when the filetype is empty):
+  AssertEqual
+  \ 0,
+  \ ale#ShouldDoNothing(bufnr('')),
+  \ 'ShouldDoNothing() was 1 for some other reason'
+
+  set filetype=
+
+  AssertEqual 1, ale#ShouldDoNothing(bufnr(''))
+
+Execute(DoNothing should return 1 when an operator is pending):
+  let b:fake_mode = 'no'
+
+  AssertEqual 1, ale#ShouldDoNothing(bufnr(''))
+
+Execute(DoNothing should return 1 for diff buffers):
+  let &diff = 1
+
+  AssertEqual 1, ale#ShouldDoNothing(bufnr(''))
+
+Execute(The DoNothing check should work if the ALE globals aren't defined):
+  unlet! g:ale_filetype_blacklist
+  unlet! g:ale_maximum_file_size
+  unlet! g:ale_enabled
+
+  " This shouldn't throw exceptions.
+  call ale#ShouldDoNothing(bufnr(''))