You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
330 lines
6.7 KiB
Plaintext
330 lines
6.7 KiB
Plaintext
After:
|
|
unlet! b:temp_name
|
|
unlet! b:other_bufnr
|
|
|
|
Given foo (Some file with lines to count):
|
|
foo12345678
|
|
bar12345678
|
|
baz12345678
|
|
four12345678
|
|
five12345678
|
|
six12345678
|
|
seven12345678
|
|
eight12345678
|
|
nine12345678
|
|
ten12345678
|
|
|
|
Execute(FixLocList should set all the default values correctly):
|
|
AssertEqual
|
|
\ [
|
|
\ {
|
|
\ 'text': 'a',
|
|
\ 'lnum': 2,
|
|
\ 'col': 0,
|
|
\ 'bufnr': bufnr('%'),
|
|
\ 'vcol': 0,
|
|
\ 'type': 'E',
|
|
\ 'nr': -1,
|
|
\ 'linter_name': 'foobar',
|
|
\ },
|
|
\ {
|
|
\ 'text': 'b',
|
|
\ 'lnum': 2,
|
|
\ 'col': 0,
|
|
\ 'bufnr': bufnr('%'),
|
|
\ 'vcol': 0,
|
|
\ 'type': 'E',
|
|
\ 'nr': -1,
|
|
\ 'linter_name': 'foobar',
|
|
\ },
|
|
\],
|
|
\ ale#engine#FixLocList(
|
|
\ bufnr('%'),
|
|
\ 'foobar',
|
|
\ [{'text': 'a', 'lnum': 2}, {'text': 'b', 'lnum': 2}],
|
|
\ )
|
|
|
|
Execute(FixLocList should use the values we supply):
|
|
AssertEqual
|
|
\ [
|
|
\ {
|
|
\ 'text': 'a',
|
|
\ 'lnum': 3,
|
|
\ 'col': 4,
|
|
\ 'bufnr': 10000,
|
|
\ 'vcol': 1,
|
|
\ 'type': 'W',
|
|
\ 'nr': 42,
|
|
\ 'linter_name': 'foobar',
|
|
\ },
|
|
\],
|
|
\ ale#engine#FixLocList(
|
|
\ bufnr('%'),
|
|
\ 'foobar',
|
|
\ [{
|
|
\ 'text': 'a',
|
|
\ 'lnum': 3,
|
|
\ 'col': 4,
|
|
\ 'bufnr': 10000,
|
|
\ 'vcol': 1,
|
|
\ 'type': 'W',
|
|
\ 'nr': 42,
|
|
\ }],
|
|
\ )
|
|
|
|
Execute(FixLocList should set items with lines beyond the end to the last line):
|
|
AssertEqual
|
|
\ [
|
|
\ {
|
|
\ 'text': 'a',
|
|
\ 'lnum': 10,
|
|
\ 'col': 0,
|
|
\ 'bufnr': bufnr('%'),
|
|
\ 'vcol': 0,
|
|
\ 'type': 'E',
|
|
\ 'nr': -1,
|
|
\ 'linter_name': 'foobar',
|
|
\ },
|
|
\],
|
|
\ ale#engine#FixLocList(
|
|
\ bufnr('%'),
|
|
\ 'foobar',
|
|
\ [{'text': 'a', 'lnum': 11}],
|
|
\ )
|
|
|
|
Execute(FixLocList should move line 0 to line 1):
|
|
AssertEqual
|
|
\ [
|
|
\ {
|
|
\ 'text': 'a',
|
|
\ 'lnum': 1,
|
|
\ 'col': 0,
|
|
\ 'bufnr': bufnr('%'),
|
|
\ 'vcol': 0,
|
|
\ 'type': 'E',
|
|
\ 'nr': -1,
|
|
\ 'linter_name': 'foobar',
|
|
\ },
|
|
\],
|
|
\ ale#engine#FixLocList(
|
|
\ bufnr('%'),
|
|
\ 'foobar',
|
|
\ [{'text': 'a', 'lnum': 0}],
|
|
\ )
|
|
|
|
Execute(FixLocList should convert line and column numbers correctly):
|
|
" The numbers should be 10, not 8 as octals.
|
|
AssertEqual
|
|
\ [
|
|
\ {
|
|
\ 'text': 'a',
|
|
\ 'lnum': 10,
|
|
\ 'col': 10,
|
|
\ 'bufnr': bufnr('%'),
|
|
\ 'vcol': 0,
|
|
\ 'type': 'E',
|
|
\ 'nr': -1,
|
|
\ 'linter_name': 'foobar',
|
|
\ },
|
|
\],
|
|
\ ale#engine#FixLocList(
|
|
\ bufnr('%'),
|
|
\ 'foobar',
|
|
\ [{'text': 'a', 'lnum': '010', 'col': '010'}],
|
|
\ )
|
|
|
|
Execute(FixLocList should pass on end_col values):
|
|
" The numbers should be 10, not 8 as octals.
|
|
AssertEqual
|
|
\ [
|
|
\ {
|
|
\ 'text': 'a',
|
|
\ 'lnum': 10,
|
|
\ 'col': 10,
|
|
\ 'end_col': 12,
|
|
\ 'bufnr': bufnr('%'),
|
|
\ 'vcol': 0,
|
|
\ 'type': 'E',
|
|
\ 'nr': -1,
|
|
\ 'linter_name': 'foobar',
|
|
\ },
|
|
\ {
|
|
\ 'text': 'a',
|
|
\ 'lnum': 10,
|
|
\ 'col': 11,
|
|
\ 'end_col': 12,
|
|
\ 'bufnr': bufnr('%'),
|
|
\ 'vcol': 0,
|
|
\ 'type': 'E',
|
|
\ 'nr': -1,
|
|
\ 'linter_name': 'foobar',
|
|
\ },
|
|
\],
|
|
\ ale#engine#FixLocList(
|
|
\ bufnr('%'),
|
|
\ 'foobar',
|
|
\ [
|
|
\ {'text': 'a', 'lnum': '010', 'col': '010', 'end_col': '012'},
|
|
\ {'text': 'a', 'lnum': '010', 'col': '011', 'end_col': 12},
|
|
\ ],
|
|
\ )
|
|
|
|
Execute(FixLocList should pass on end_lnum values):
|
|
AssertEqual
|
|
\ [
|
|
\ {
|
|
\ 'text': 'a',
|
|
\ 'lnum': 10,
|
|
\ 'col': 10,
|
|
\ 'end_lnum': 13,
|
|
\ 'end_col': 12,
|
|
\ 'bufnr': bufnr('%'),
|
|
\ 'vcol': 0,
|
|
\ 'type': 'E',
|
|
\ 'nr': -1,
|
|
\ 'linter_name': 'foobar',
|
|
\ },
|
|
\ {
|
|
\ 'text': 'a',
|
|
\ 'lnum': 10,
|
|
\ 'col': 11,
|
|
\ 'end_lnum': 13,
|
|
\ 'end_col': 12,
|
|
\ 'bufnr': bufnr('%'),
|
|
\ 'vcol': 0,
|
|
\ 'type': 'E',
|
|
\ 'nr': -1,
|
|
\ 'linter_name': 'foobar',
|
|
\ },
|
|
\],
|
|
\ ale#engine#FixLocList(
|
|
\ bufnr('%'),
|
|
\ 'foobar',
|
|
\ [
|
|
\ {'text': 'a', 'lnum': '010', 'col': '010', 'end_col': '012', 'end_lnum': '013'},
|
|
\ {'text': 'a', 'lnum': '010', 'col': '011', 'end_col': 12, 'end_lnum': 13},
|
|
\ ],
|
|
\ )
|
|
|
|
Execute(FixLocList should allow subtypes to be set):
|
|
AssertEqual
|
|
\ [
|
|
\ {
|
|
\ 'text': 'a',
|
|
\ 'lnum': 10,
|
|
\ 'col': 0,
|
|
\ 'bufnr': bufnr('%'),
|
|
\ 'vcol': 0,
|
|
\ 'type': 'E',
|
|
\ 'sub_type': 'style',
|
|
\ 'nr': -1,
|
|
\ 'linter_name': 'foobar',
|
|
\ },
|
|
\],
|
|
\ ale#engine#FixLocList(
|
|
\ bufnr('%'),
|
|
\ 'foobar',
|
|
\ [{'text': 'a', 'lnum': 11, 'sub_type': 'style'}],
|
|
\ )
|
|
|
|
Execute(FixLocList should accept filenames):
|
|
let b:other_bufnr = bufnr('/foo/bar/baz', 1)
|
|
|
|
" Make sure we actually get another buffer number, or the test is invalid.
|
|
AssertNotEqual -1, b:other_bufnr
|
|
|
|
call ale#test#SetFilename('test.txt')
|
|
|
|
AssertEqual
|
|
\ [
|
|
\ {
|
|
\ 'text': 'a',
|
|
\ 'lnum': 2,
|
|
\ 'col': 0,
|
|
\ 'bufnr': bufnr('%'),
|
|
\ 'filename': expand('%:p'),
|
|
\ 'vcol': 0,
|
|
\ 'type': 'E',
|
|
\ 'nr': -1,
|
|
\ 'linter_name': 'foobar',
|
|
\ },
|
|
\ {
|
|
\ 'text': 'a',
|
|
\ 'lnum': 3,
|
|
\ 'col': 0,
|
|
\ 'bufnr': bufnr('%'),
|
|
\ 'filename': expand('%:p'),
|
|
\ 'vcol': 0,
|
|
\ 'type': 'E',
|
|
\ 'nr': -1,
|
|
\ 'linter_name': 'foobar',
|
|
\ },
|
|
\ {
|
|
\ 'text': 'a',
|
|
\ 'lnum': 4,
|
|
\ 'col': 0,
|
|
\ 'bufnr': b:other_bufnr,
|
|
\ 'filename': '/foo/bar/baz',
|
|
\ 'vcol': 0,
|
|
\ 'type': 'E',
|
|
\ 'nr': -1,
|
|
\ 'linter_name': 'foobar',
|
|
\ },
|
|
\ {
|
|
\ 'text': 'a',
|
|
\ 'lnum': 5,
|
|
\ 'col': 0,
|
|
\ 'bufnr': b:other_bufnr,
|
|
\ 'filename': '/foo/bar/baz',
|
|
\ 'vcol': 0,
|
|
\ 'type': 'E',
|
|
\ 'nr': -1,
|
|
\ 'linter_name': 'foobar',
|
|
\ },
|
|
\],
|
|
\ ale#engine#FixLocList(
|
|
\ bufnr('%'),
|
|
\ 'foobar',
|
|
\ [
|
|
\ {'text': 'a', 'lnum': 2, 'filename': expand('%:p')},
|
|
\ {'text': 'a', 'lnum': 3, 'filename': expand('%:p')},
|
|
\ {'text': 'a', 'lnum': 4, 'filename': '/foo/bar/baz'},
|
|
\ {'text': 'a', 'lnum': 5, 'filename': '/foo/bar/baz'},
|
|
\ ],
|
|
\ )
|
|
|
|
Execute(FixLocList should interpret temporary filenames as being the current buffer):
|
|
let b:temp_name = tempname()
|
|
|
|
AssertEqual
|
|
\ [
|
|
\ {
|
|
\ 'text': 'a',
|
|
\ 'lnum': 2,
|
|
\ 'col': 0,
|
|
\ 'bufnr': bufnr(''),
|
|
\ 'vcol': 0,
|
|
\ 'type': 'E',
|
|
\ 'nr': -1,
|
|
\ 'linter_name': 'foobar',
|
|
\ },
|
|
\ {
|
|
\ 'text': 'a',
|
|
\ 'lnum': 3,
|
|
\ 'col': 0,
|
|
\ 'bufnr': bufnr(''),
|
|
\ 'vcol': 0,
|
|
\ 'type': 'E',
|
|
\ 'nr': -1,
|
|
\ 'linter_name': 'foobar',
|
|
\ },
|
|
\],
|
|
\ ale#engine#FixLocList(
|
|
\ bufnr(''),
|
|
\ 'foobar',
|
|
\ [
|
|
\ {'text': 'a', 'lnum': 2, 'filename': b:temp_name},
|
|
\ {'text': 'a', 'lnum': 3, 'filename': b:temp_name},
|
|
\ ],
|
|
\ )
|