ale/test/test_loclist_sorting.vader

32 lines
936 B
Plaintext
Raw Normal View History

Before:
let g:loclist = [
\ {'bufnr': 3, 'lnum': 1, 'col': 1},
\ {'bufnr': 1, 'lnum': 5, 'col': 5},
\ {'bufnr': 2, 'lnum': 5, 'col': 5},
\ {'bufnr': 1, 'lnum': 5, 'col': 4},
\ {'bufnr': 1, 'lnum': 2, 'col': 10},
\ {'bufnr': 2, 'lnum': 1, 'col': 5},
\ {'bufnr': 1, 'lnum': 3, 'col': 2},
\ {'bufnr': 2, 'lnum': 1, 'col': 2},
\ {'bufnr': -1, 'lnum': 3, 'col': 2},
\]
Execute (Sort loclist with comparison function):
call sort(g:loclist, 'ale#util#LocItemCompare')
Then (loclist item should be sorted):
AssertEqual [
\ {'bufnr': -1, 'lnum': 3, 'col': 2},
\ {'bufnr': 1, 'lnum': 2, 'col': 10},
\ {'bufnr': 1, 'lnum': 3, 'col': 2},
\ {'bufnr': 1, 'lnum': 5, 'col': 4},
\ {'bufnr': 1, 'lnum': 5, 'col': 5},
\ {'bufnr': 2, 'lnum': 1, 'col': 2},
\ {'bufnr': 2, 'lnum': 1, 'col': 5},
\ {'bufnr': 2, 'lnum': 5, 'col': 5},
\ {'bufnr': 3, 'lnum': 1, 'col': 1},
\], g:loclist
After:
unlet g:loclist