summaryrefslogtreecommitdiff
path: root/test/test_cursor_warnings.vader
blob: 75d6c9759045e39ccc0cb2b20d9d0c71711d123f (plain)
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
Before:
  let g:ale_buffer_info = {
  \ bufnr('%'): {
  \   'loclist': [
  \     {
  \       'lnum': 1,
  \       'bufnr': bufnr('%'),
  \       'vcol': 0,
  \       'linter_name': 'eslint',
  \       'nr': -1,
  \       'type': 'E',
  \       'col': 10,
  \       'text': 'Missing semicolon. (semi)',
  \       'detail': 'Every statement should end with a semicolon'
  \     },
  \     {
  \       'lnum': 2,
  \       'bufnr': bufnr('%'),
  \       'vcol': 0,
  \       'linter_name': 'eslint',
  \       'nr': -1,
  \       'type': 'W',
  \       'col': 10,
  \       'text': 'Infix operators must be spaced. (space-infix-ops)'
  \     },
  \     {
  \       'lnum': 2,
  \       'bufnr': bufnr('%'),
  \       'vcol': 0,
  \       'linter_name': 'eslint',
  \       'nr': -1,
  \       'type': 'E',
  \       'col': 15,
  \       '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

After:
  let g:ale_set_loclist = 1
  let g:ale_set_signs = 1
  let g:ale_set_highlights = 1

  unlet! g:output
  unlet! g:lines
  let g:ale_buffer_info = {}

Given javascript(A Javscript file with warnings/errors):
  var x = 3
  var x = 5*2 + parseInt("10");

Execute(Evaluate the cursor function at line 1):
  :1
  call ale#cursor#EchoCursorWarning()

Then(Check the cursor output):
  redir => g:output
    silent mess
  redir END

  let g:lines = split(g:output, "\n")

  AssertEqual 'Missing semicolon. (semi)', g:lines[-1]

Execute(Evaluate the cursor function at line 2):
  :2
  call ale#cursor#EchoCursorWarning()

Then(Check the cursor output):
  redir => g:output
    silent mess
  redir END

  let g:lines = split(g:output, "\n")

  AssertEqual 'Infix operators must be spaced. (space-infix-ops)', g:lines[-1]

Execute(Evaluate the cursor function later in line 2):
  :2
  normal 16l
  call ale#cursor#EchoCursorWarning()

Then(Check the cursor output):
  redir => g:output
    silent mess
  redir END

  let g:lines = split(g:output, "\n")

  AssertEqual 'Missing radix parameter (radix)', g:lines[-1]

Execute(Set results for a lint cycle, with the cursor on line 1):
  :1
  call ale#engine#SetResults(
  \ bufnr('%'),
  \ g:ale_buffer_info[bufnr('%')].loclist,
  \)

Then(Check the cursor output):
  redir => g:output
    silent mess
  redir END

  let g:lines = split(g:output, "\n")

  AssertEqual 'Missing semicolon. (semi)', g:lines[-1]

Execute(Simulate leaving insert mode on line 2):
  :2
  normal 16h
  doautocmd InsertLeave

Then(Check the cursor output):
  redir => g:output
    silent mess
  redir END

  let g:lines = split(g:output, "\n")

  AssertEqual 'Infix operators must be spaced. (space-infix-ops)', g:lines[-1]

Execute(Evaluate the cursor detail function at line 1):
  :1
  call ale#cursor#ShowCursorDetail()

Then(Check the cursor output):
  redir => g:output
    :mess
  redir END

  AssertEqual "Every statement should end with a semicolon", g:lines[-1]

Execute(Evaluate the cursor detail function at line 2):
  :2
  call ale#cursor#ShowCursorDetail()

Then(Check the cursor output):
  redir => g:output
    :mess
  redir END

  AssertEqual "Infix operators must be spaced. (space-infix-ops)", g:lines[-1]