]> git.madduck.net Git - etc/vim.git/blobdiff - .vim/bundle/ale/test/sign/test_sign_limits.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 / sign / test_sign_limits.vader
diff --git a/.vim/bundle/ale/test/sign/test_sign_limits.vader b/.vim/bundle/ale/test/sign/test_sign_limits.vader
new file mode 100644 (file)
index 0000000..2b4942e
--- /dev/null
@@ -0,0 +1,52 @@
+Before:
+  Save g:ale_max_signs
+
+  let g:ale_max_signs = -1
+
+  function! SetNProblems(sign_count)
+    let l:loclist = []
+    let l:range = range(1, a:sign_count)
+    call setline(1, l:range)
+
+    for l:index in l:range
+      call add(l:loclist, {
+      \ 'bufnr': bufnr(''),
+      \ 'lnum': l:index,
+      \ 'col': 1,
+      \ 'type': 'E',
+      \ 'text': 'a',
+      \})
+    endfor
+
+    call ale#sign#SetSigns(bufnr(''), l:loclist)
+
+    return sort(map(ale#sign#FindCurrentSigns(bufnr(''))[1], 'v:val[0]'), 'n')
+  endfunction
+
+After:
+  Restore
+
+  unlet! b:ale_max_signs
+
+  delfunction SetNProblems
+
+  call ale#sign#Clear()
+
+Execute(There should be no limit on signs with negative numbers):
+  AssertEqual range(1, 42), SetNProblems(42)
+
+Execute(0 signs should be set when the max is 0):
+  let g:ale_max_signs = 0
+
+  AssertEqual [], SetNProblems(42)
+
+Execute(10 signs should be set when the max is 10):
+  let g:ale_max_signs = 10
+
+  " We'll check that we set signs for the first 10 items, not other lines.
+  AssertEqual range(1, 10), SetNProblems(42)
+
+Execute(5 signs should be set when the max is 5 for the buffer):
+  let b:ale_max_signs = 5
+
+  AssertEqual range(1, 5), SetNProblems(42)