]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/handler/test_elmmake_handler.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 / handler / test_elmmake_handler.vader
1 Before:
2   runtime ale_linters/elm/make.vim
3
4 After:
5   unlet! g:config_error_lines
6
7   call ale#linter#Reset()
8
9
10 " Elm 0.19
11
12 Execute(The elm-make handler should parse Elm 0.19 general problems correctly):
13   AssertEqual
14   \ [
15   \   {
16   \     'lnum': 1,
17   \     'type': 'E',
18   \     'text': "error details\n\nstyled details"
19   \   }
20   \ ],
21   \ ale_linters#elm#make#Handle(347, [
22   \   json_encode({
23   \     'type': 'error',
24   \     'path': ale#util#Tempname() . '/Module.elm',
25   \     'title': 'UNKNOWN IMPORT',
26   \     'message': ["error details\n\n", { 'string': 'styled details' }]
27   \   }),
28   \ ])
29
30 Execute(The elm-make handler should parse Elm 0.19 compilation errors correctly):
31   AssertEqual
32   \ [
33   \   {
34   \     'lnum': 404,
35   \     'col': 1,
36   \     'end_lnum': 408,
37   \     'end_col': 18,
38   \     'type': 'E',
39   \     'text': "error details 1\n\nstyled details"
40   \   },
41   \   {
42   \     'lnum': 406,
43   \     'col': 5,
44   \     'end_lnum': 407,
45   \     'end_col': 17,
46   \     'type': 'E',
47   \     'text': 'error details 2',
48   \   },
49   \   {
50   \     'lnum': 406,
51   \     'col': 5,
52   \     'end_lnum': 406,
53   \     'end_col': 93,
54   \     'type': 'E',
55   \     'text': 'error details 3',
56   \   },
57   \ ],
58   \ ale_linters#elm#make#Handle(347, [
59   \   json_encode({
60   \      'type': 'compile-errors',
61   \      'errors': [
62   \        {
63   \          'path': ale#util#Tempname() . '/Module.elm',
64   \          'problems': [
65   \            {
66   \              'title': 'TYPE MISMATCH',
67   \              'message': ["error details 1\n\n", { 'string': 'styled details' }],
68   \              'region': { 'start': { 'line': 404, 'column': 1 }, 'end': { 'line': 408, 'column': 18 } }
69   \            },
70   \            {
71   \              'title': 'TYPE MISMATCH',
72   \              'message': ['error details 2'],
73   \              'region': { 'start': {'line': 406, 'column': 5}, 'end': {'line': 407, 'column': 17 } }
74   \            },
75   \            {
76   \              'title': 'TYPE MISMATCH',
77   \              'message': ['error details 3'],
78   \              'region': { 'start': { 'line': 406, 'column': 5}, 'end': {'line': 406, 'column': 93 } }
79   \            }
80   \          ]
81   \        }
82   \      ]
83   \    }),
84   \ ])
85
86 Execute(The elm-make handler should handle errors in Elm 0.19 imported modules):
87   AssertEqual
88   \ [
89   \   {
90   \     'lnum': 1,
91   \     'type': 'E',
92   \     'text': "src/Module.elm - error details\n\nstyled details",
93   \     'detail': "src/Module.elm ----------\n\nerror details\n\nstyled details"
94   \   },
95   \   {
96   \     'lnum': 1,
97   \     'type': 'E',
98   \     'text': "Elm - error details\n\nstyled details",
99   \     'detail': "Elm ----------\n\nerror details\n\nstyled details"
100   \   },
101   \   {
102   \     'lnum': 1,
103   \     'type': 'E',
104   \     'text': "src/Module.elm:404 - error details\n\nstyled details",
105   \     'detail': "src/Module.elm:404 ----------\n\nerror details\n\nstyled details"
106   \   },
107   \ ],
108   \ ale_linters#elm#make#Handle(347, [
109   \   json_encode({
110   \      'type': 'error',
111   \      'path': 'src/Module.elm',
112   \      'title': 'UNKNOWN IMPORT',
113   \      'message': ["error details\n\n", { 'string': 'styled details' }]
114   \    }),
115   \   json_encode({
116   \      'type': 'error',
117   \      'path': v:null,
118   \      'title': 'UNKNOWN IMPORT',
119   \      'message': ["error details\n\n", { 'string': 'styled details' }]
120   \    }),
121   \   json_encode({
122   \      'type': 'compile-errors',
123   \      'errors': [
124   \        {
125   \          'path': 'src/Module.elm',
126   \          'problems': [
127   \            {
128   \              'title': 'TYPE MISMATCH',
129   \              'message': ["error details\n\n", { 'string': 'styled details' }],
130   \              'region': { 'start': { 'line': 404, 'column': 1 }, 'end': { 'line': 408, 'column': 18 } }
131   \            }
132   \          ]
133   \        }
134   \      ]
135   \    }),
136   \ ])
137
138
139 " Elm 0.18
140
141 Execute(The elm-make handler should parse Elm 0.18 compilation errors correctly):
142   AssertEqual
143   \ [
144   \   {
145   \     'lnum': 33,
146   \     'col': 1,
147   \     'end_lnum': 33,
148   \     'end_col': 19,
149   \     'type': 'W',
150   \     'text': 'warning overview',
151   \     'detail': "warning overview\n\nwarning details",
152   \   },
153   \   {
154   \     'lnum': 404,
155   \     'col': 1,
156   \     'end_lnum': 408,
157   \     'end_col': 18,
158   \     'type': 'E',
159   \     'text': 'error overview 1',
160   \     'detail': "error overview 1\n\nerror details 1",
161   \   },
162   \   {
163   \     'lnum': 406,
164   \     'col': 5,
165   \     'end_lnum': 407,
166   \     'end_col': 17,
167   \     'type': 'E',
168   \     'text': 'error overview 2',
169   \     'detail': "error overview 2\n\nerror details 2",
170   \   },
171   \   {
172   \     'lnum': 406,
173   \     'col': 5,
174   \     'end_lnum': 406,
175   \     'end_col': 93,
176   \     'type': 'E',
177   \     'text': 'error overview 3',
178   \     'detail': "error overview 3\n\nerror details 3",
179   \   },
180   \ ],
181   \ ale_linters#elm#make#Handle(347, [
182   \   json_encode([
183   \      {
184   \         'tag': 'unused import',
185   \         'overview': 'warning overview',
186   \         'details': 'warning details',
187   \         'region': {'start': { 'line': 33, 'column': 1 }, 'end': { 'line': 33, 'column': 19 } },
188   \         'type': 'warning',
189   \         'file': ale#util#Tempname() . '/Module.elm',
190   \      }
191   \    ]),
192   \   json_encode([
193   \      {
194   \        'tag': 'TYPE MISMATCH',
195   \        'overview': 'error overview 1',
196   \        'subregion': { 'start': { 'line': 406, 'column': 5 }, 'end': { 'line': 408, 'column': 18 } },
197   \        'details': 'error details 1',
198   \        'region': { 'start': { 'line': 404, 'column': 1 }, 'end': { 'line': 408, 'column': 18 } },
199   \        'type': 'error',
200   \        'file': ale#util#Tempname() . '/Module.elm',
201   \      },
202   \      {
203   \        'tag': 'TYPE MISMATCH',
204   \        'overview': 'error overview 2',
205   \        'subregion': { 'start': { 'line': 407, 'column': 12 }, 'end': { 'line': 407, 'column': 17 } },
206   \        'details': 'error details 2',
207   \        'region': { 'start': { 'line': 406, 'column': 5}, 'end': { 'line': 407, 'column': 17 } },
208   \        'type':'error',
209   \        'file': ale#util#Tempname() . '/Module.elm',
210   \      },
211   \      {
212   \        'tag': 'TYPE MISMATCH',
213   \        'overview': 'error overview 3',
214   \        'subregion': { 'start': { 'line': 406, 'column': 88 }, 'end': { 'line': 406, 'column': 93 } },
215   \        'details': 'error details 3',
216   \        'region': { 'start': { 'line': 406, 'column': 5 }, 'end': { 'line': 406, 'column': 93 } },
217   \        'type':'error',
218   \        'file': ale#util#Tempname() . '/Module.elm',
219   \      }
220   \    ]),
221   \ ])
222
223 Execute(The elm-make handler should handle errors in Elm 0.18 imported modules):
224   AssertEqual
225   \ [
226   \   {
227   \     'lnum': 1,
228   \     'type': 'E',
229   \     'text': 'src/Module.elm:33 - error overview',
230   \     'detail': "src/Module.elm:33 ----------\n\nerror overview\n\nerror details"
231   \   }
232   \ ],
233   \ ale_linters#elm#make#Handle(347, [
234   \   json_encode([
235   \      {
236   \         'tag': 'unused import',
237   \         'overview': 'warning overview',
238   \         'details': 'warning details',
239   \         'region': {'start': { 'line': 33, 'column': 1 }, 'end': { 'line': 33, 'column': 19 } },
240   \         'type': 'warning',
241   \         'file': 'src/Module.elm',
242   \      },
243   \      {
244   \         'tag': 'type error',
245   \         'overview': 'error overview',
246   \         'details': 'error details',
247   \         'region': {'start': { 'line': 33, 'column': 1 }, 'end': { 'line': 33, 'column': 19 } },
248   \         'type': 'error',
249   \         'file': 'src/Module.elm',
250   \      }
251   \    ]),
252   \ ])
253
254 " Generic
255
256 Execute(The elm-make handler should put an error on the first line if a line cannot be parsed):
257   AssertEqual
258   \ [
259   \   {
260   \     'lnum': 404,
261   \     'col': 1,
262   \     'end_lnum': 408,
263   \     'end_col': 18,
264   \     'type': 'E',
265   \     'text': "error details 1\n\nstyled details"
266   \   },
267   \   {
268   \     'lnum': 1,
269   \     'type': 'E',
270   \     'text': 'Not JSON',
271   \     'detail': "Not JSON\nAlso not JSON",
272   \   },
273   \ ],
274   \ ale_linters#elm#make#Handle(347, [
275   \   json_encode({
276   \      'type': 'compile-errors',
277   \      'errors': [
278   \        {
279   \          'path': ale#util#Tempname() . '/Module.elm',
280   \          'problems': [
281   \            {
282   \              'title': 'TYPE MISMATCH',
283   \              'message': ["error details 1\n\n", { 'string': 'styled details' }],
284   \              'region': { 'start': { 'line': 404, 'column': 1 }, 'end': { 'line': 408, 'column': 18 } }
285   \            }
286   \          ]
287   \        }
288   \      ]
289   \    }),
290   \    'Not JSON',
291   \    'Also not JSON',
292   \ ])
293
294 Execute(The elm-make handler should ignore success lines):
295   AssertEqual
296   \ [],
297   \ ale_linters#elm#make#Handle(347, [
298   \    'Successfully generated /dev/null',
299   \ ])