1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
Before:
let g:ale_buffer_info = {
\ bufnr('%'): {
\ 'loclist': [
\ {
\ 'lnum': 1,
\ 'col': 10,
\ 'bufnr': bufnr('%'),
\ 'vcol': 0,
\ 'linter_name': 'eslint',
\ 'nr': -1,
\ 'type': 'E',
\ 'text': 'Missing semicolon. (semi)',
\ 'detail': 'Every statement should end with a semicolon'
\ },
\ {
\ 'lnum': 2,
\ 'col': 10,
\ 'bufnr': bufnr('%'),
\ 'vcol': 0,
\ 'linter_name': 'eslint',
\ 'nr': -1,
\ 'type': 'W',
\ 'text': 'Infix operators must be spaced. (space-infix-ops)'
\ },
\ {
\ 'lnum': 2,
\ 'col': 15,
\ 'bufnr': bufnr('%'),
\ 'vcol': 0,
\ 'linter_name': 'eslint',
\ 'nr': -1,
\ 'type': 'E',
\ 'text': 'Missing radix parameter (radix)'
\ }
\ ],
\ },
\}
" Turn off other features, we only care about this one feature in this test.
let g:ale_set_loclist = 0
let g:ale_set_signs = 0
let g:ale_set_highlights = 0
function GetLastMessage()
redir => l:output
silent mess
redir END
let l:lines = split(l:output, "\n")
return empty(l:lines) ? '' : l:lines[-1]
endfunction
After:
call cursor(1, 1)
let g:ale_set_loclist = 1
let g:ale_set_signs = 1
let g:ale_set_highlights = 1
let g:ale_buffer_info = {}
delfunction GetLastMessage
mess clear
Given javascript(A Javscript file with warnings/errors):
var x = 3
var x = 5*2 + parseInt("10");
Execute(Messages should be shown for the correct lines):
call cursor(1, 1)
call ale#cursor#EchoCursorWarning()
AssertEqual 'Missing semicolon. (semi)', GetLastMessage()
Execute(Messages should be shown for earlier columns):
call cursor(2, 1)
call ale#cursor#EchoCursorWarning()
AssertEqual 'Infix operators must be spaced. (space-infix-ops)', GetLastMessage()
Execute(Messages should be shown for later columns):
call cursor(2, 16)
call ale#cursor#EchoCursorWarning()
AssertEqual 'Missing radix parameter (radix)', GetLastMessage()
Execute(The message at the cursor should be shown when linting ends):
call cursor(1, 1)
call ale#engine#SetResults(
\ bufnr('%'),
\ g:ale_buffer_info[bufnr('%')].loclist,
\)
AssertEqual 'Missing semicolon. (semi)', GetLastMessage()
Execute(The message at the cursor should be shown on InsertLeave):
call cursor(2, 9)
doautocmd InsertLeave
AssertEqual 'Infix operators must be spaced. (space-infix-ops)', GetLastMessage()
Execute(ALEDetail should print 'detail' attributes):
call cursor(1, 1)
ALEDetail
AssertEqual "Every statement should end with a semicolon", GetLastMessage()
Execute(ALEDetail should print regular 'text' attributes):
call cursor(2, 10)
ALEDetail
AssertEqual "Infix operators must be spaced. (space-infix-ops)", GetLastMessage()
|