]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/handler/test_perl6_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 '56df844d3c39ec494dacc69eae34272b27db185a' as '.vim/bundle/asyncomplete'
[etc/vim.git] / .vim / bundle / ale / test / handler / test_perl6_handler.vader
1 Before:
2   call ale#test#SetDirectory('/testplugin/test/handler')
3
4   runtime ale_linters/perl6/perl6.vim
5
6 After:
7   call ale#test#RestoreDirectory()
8   call ale#linter#Reset()
9
10 Execute(The Perl6 linter should handle empty output):
11   call ale#test#SetFilename('bar.pl6')
12
13   AssertEqual [], ale_linters#perl6#perl6#Handle(bufnr(''), [])
14
15 Execute(The Perl6 linter should complain about undeclared variables):
16   call ale#test#SetFilename('bar.pl6')
17
18   AssertEqual
19   \ [
20   \   {
21   \    'lnum': '6',
22   \    'text': 'Variable ''$tes'' is not declared. Did you mean any of these? $res $test ',
23   \    'type': 'E',
24   \    'col': '',
25   \    'end_lnum': '',
26   \    'code': 'X::Undeclared',
27   \   }
28   \ ],
29   \ ale_linters#perl6#perl6#Handle(bufnr(''), [
30   \ '{
31   \   "X::Undeclared" : {
32   \     "highexpect" : [ ],
33   \     "is-compile-time" : 1,
34   \     "modules" : [ ],
35   \     "column" : null,
36   \     "pos" : 18,
37   \     "symbol" : "$tes",
38   \     "filename" : "bar.pl6",
39   \     "what" : "Variable",
40   \     "pre" : "my $test = 0; say ",
41   \     "post" : "$tes",
42   \     "suggestions" : [
43   \       "$res",
44   \       "$test"
45   \     ],
46   \     "line" : 6,
47   \     "message" : "Variable ''$tes'' is not declared. Did you mean any of these?\n    $res\n    $test\n"
48   \   }
49   \ }'
50   \ ])
51
52 Execute(The Perl6 linter should complain about Comp::AdHoc errors):
53   call ale#test#SetFilename('bar.pl6')
54
55   AssertEqual
56   \ [
57   \   {
58   \     'lnum': '3',
59   \     'type': 'E',
60   \     'text': 'is repr(...) trait needs a parameter',
61   \     'col': '',
62   \     'end_lnum': '',
63   \     'code': 'X::Comp::AdHoc',
64   \   }
65   \ ],
66   \ ale_linters#perl6#perl6#Handle(bufnr(''), [
67   \ '{
68   \   "X::Comp::AdHoc" : {
69   \     "pre" : "class test is repr",
70   \     "message" : "is repr(...) trait needs a parameter",
71   \     "line" : 3,
72   \     "post" : " {}",
73   \     "is-compile-time" : true,
74   \     "pos" : 19,
75   \     "highexpect" : [ ],
76   \     "payload" : "is repr(...) trait needs a parameter",
77   \     "filename" : "bar.pl6",
78   \     "column" : null,
79   \     "modules" : [ ]
80   \   }
81   \ }'
82   \])
83
84 Execute(The Perl6 linter should be able to extract a line number from an error message):
85   call ale#test#SetFilename('bar.pl6')
86
87   AssertEqual
88   \ [
89   \   {
90   \    'lnum': '3',
91   \    'text': 'Could not find Module::Does::not::exist at line 3 in: /usr/share/perl6/site /usr/share/perl6/vendor /usr/share/perl6 CompUnit::Repository::AbsolutePath<94023691448416> CompUnit::Repository::NQP<94023670532736> CompUnit::Repository::Perl5<94023670532776>',
92   \    'col': '',
93   \    'type': 'E',
94   \    'end_lnum': '',
95   \    'code': 'X::CompUnit::UnsatisfiedDependency',
96   \   }
97   \ ],
98   \ ale_linters#perl6#perl6#Handle(bufnr(''), [
99   \ '{
100   \   "X::CompUnit::UnsatisfiedDependency" : {
101   \   "message" : "Could not find Module::Does::not::exist at line 3 in:\n    /usr/share/perl6/site\n    /usr/share/perl6/vendor\n    /usr/share/perl6\n    CompUnit::Repository::AbsolutePath<94023691448416>\n    CompUnit::Repository::NQP<94023670532736>\n    CompUnit::Repository::Perl5<94023670532776>",
102   \   "specification" : "Module::Does::not::exist"
103   \   }
104   \ }'
105   \ ])
106
107 Execute(The Perl6 linter should be able to differentiate between warnings and errors):
108   call ale#test#SetFilename('bar.pl6')
109
110   AssertEqual
111   \ [
112   \   {
113   \    'lnum': '1',
114   \    'col': '',
115   \    'code': 'X::Syntax::Regex::Unterminated',
116   \    'end_lnum': '',
117   \    'type': 'E',
118   \    'text': 'Regex not terminated.',
119   \   },
120   \   {
121   \    'lnum': '1',
122   \    'col': '',
123   \    'code': 'X::Comp::AdHoc',
124   \    'end_lnum': '',
125   \    'type': 'W',
126   \    'text': 'Space is not significant here; please use quotes or :s (:sigspace) modifier (or, to suppress this warning, omit the space, or otherwise change the spacing)',
127   \   }
128   \ ],
129   \ ale_linters#perl6#perl6#Handle(bufnr(''), [
130   \ '{
131   \   "X::Comp::Group" : {
132   \     "message" : "Regex not terminated.\nUnable to parse regex; couldn''t find final ''/''\nSpace is not significant here; please use quotes or :s (:sigspace) modifier (or, to suppress this warning, omit the space, or otherwise change the spacing)",
133   \     "panic" : "Unable to parse regex; couldn''t find final ''/''",
134   \     "sorrows" : [
135   \       {
136   \         "X::Syntax::Regex::Unterminated" : {
137   \           "highexpect" : [
138   \             "infix stopper"
139   \           ],
140   \           "pos" : 6,
141   \           "is-compile-time" : 1,
142   \           "modules" : [ ],
143   \           "post" : "<EOL>",
144   \           "message" : "Regex not terminated.",
145   \           "line" : 1,
146   \           "filename" : "bar.pl6",
147   \           "column" : null,
148   \           "pre" : "/win 3"
149   \         }
150   \       }
151   \     ],
152   \     "worries" : [
153   \       {
154   \         "X::Comp::AdHoc" : {
155   \           "filename" : "bar.pl6",
156   \           "line" : 1,
157   \           "column" : null,
158   \           "pre" : "/win",
159   \           "highexpect" : [ ],
160   \           "payload" : "Space is not significant here; please use quotes or :s (:sigspace) modifier (or, to suppress this warning, omit the space, or otherwise change the spacing)",
161   \           "post" : " 3",
162   \           "message" : "Space is not significant here; please use quotes or :s (:sigspace) modifier (or, to suppress this warning, omit the space, or otherwise change the spacing)",
163   \           "modules" : [ ],
164   \           "is-compile-time" : true,
165   \           "pos" : 4
166   \         }
167   \       }
168   \     ]
169   \   }
170   \ }'
171   \])
172
173 Execute(The Perl6 linter should gracefully handle non-JSON messages):
174   call ale#test#SetFilename('bar.pl6')
175
176   AssertEqual
177   \ [
178   \   {
179   \    'lnum': '1',
180   \    'text': 'Received output in the default Perl6 error format. See :ALEDetail for details',
181   \    'type': 'W',
182   \    'detail': join([
183   \    'Potential difficulties:',
184   \    '    Redeclaration of symbol ''$_''',
185   \    '    at /home/travis/perl6-error-fail/insanity-test.pl6:1',
186   \    '    ------>  sub foo($_) {.say}; my $_<HERE> = 1; .&foo;',
187   \    '    Space is not significant here; please use quotes or :s (:sigspace) modifier (or, to suppress this warning, omit the space, or otherwise change the spacing)',
188   \    '    at /home/travis/perl6-error-fail/insanity-test.pl6:4',
189   \    '    ------> /win<HERE> 3/',
190   \    'Syntax OK',], "\n")
191   \   }
192   \ ],
193   \ ale_linters#perl6#perl6#Handle(bufnr(''), [
194   \   'Potential difficulties:',
195   \   '    Redeclaration of symbol ''$_''',
196   \   '    at /home/travis/perl6-error-fail/insanity-test.pl6:1',
197   \   '    ------>  sub foo($_) {.say}; my $_<HERE> = 1; .&foo;',
198   \   '    Space is not significant here; please use quotes or :s (:sigspace) modifier (or, to suppress this warning, omit the space, or otherwise change the spacing)',
199   \   '    at /home/travis/perl6-error-fail/insanity-test.pl6:4',
200   \   '    ------> /win<HERE> 3/',
201   \   'Syntax OK'
202   \ ])
203
204 Execute(The Perl6 linter should gracefully handle messages without a line number):
205   call ale#test#SetFilename('bar.pl6')
206
207   AssertEqual
208   \ [
209   \    {
210   \     'lnum': '1',
211   \     'end_lnum': '',
212   \     'text': 'Cannot find method ''has_compile_time_value'' on object of type NQPMu',
213   \     'type': 'E',
214   \     'col' : '',
215   \     'code': 'X::AdHoc',
216   \    }
217   \ ],
218   \ ale_linters#perl6#perl6#Handle(bufnr(''), [
219   \   '{',
220   \     '"X::AdHoc" : {',
221   \       '"message" : "Cannot find method ''has_compile_time_value'' on object of type NQPMu",',
222   \       '"payload" : "Cannot find method ''has_compile_time_value'' on object of type NQPMu"',
223   \      '}',
224   \    '}',
225   \ ])
226
227 Execute(The Perl6 linter should not include errors from a known separate file):
228   call ale#test#SetFilename('bar.pl6')
229
230   AssertEqual
231   \ [],
232   \ ale_linters#perl6#perl6#Handle(bufnr(''), [
233   \ '{
234   \   "X::Undeclared" : {
235   \     "highexpect" : [ ],
236   \     "is-compile-time" : 1,
237   \     "modules" : [ ],
238   \     "column" : null,
239   \     "pos" : 18,
240   \     "symbol" : "$tes",
241   \     "filename" : "foo.pl6",
242   \     "what" : "Variable",
243   \     "pre" : "my $test = 0; say ",
244   \     "post" : "$tes",
245   \     "suggestions" : [
246   \       "$res",
247   \       "$test"
248   \     ],
249   \     "line" : 6,
250   \     "message" : "Variable ''$tes'' is not declared. Did you mean any of these?\n    $res\n    $test\n"
251   \   }
252   \ }'
253   \ ])
254
255 Execute(The Perl6 linter should not ignore errors without a filename):
256   call ale#test#SetFilename('bar.pl6')
257
258   AssertEqual
259   \ [
260   \    {
261   \     'lnum': '3',
262   \     'end_lnum': '',
263   \     'text': 'Cannot find method ''has_compile_time_value'' on object of type NQPMu',
264   \     'type': 'E',
265   \     'col' : '',
266   \     'code': 'X::AdHoc',
267   \    }
268   \ ],
269   \ ale_linters#perl6#perl6#Handle(bufnr(''), [
270   \   '{',
271   \     '"X::AdHoc" : {',
272   \       '"line" : 3,',
273   \       '"message" : "Cannot find method ''has_compile_time_value'' on object of type NQPMu",',
274   \       '"payload" : "Cannot find method ''has_compile_time_value'' on object of type NQPMu"',
275   \      '}',
276   \    '}',
277   \ ])