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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
|
Before:
call ale#test#SetDirectory('/testplugin/test/handler')
runtime ale_linters/perl6/perl6.vim
After:
call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(The Perl6 linter should handle empty output):
call ale#test#SetFilename('bar.pl6')
AssertEqual [], ale_linters#perl6#perl6#Handle(bufnr(''), [])
Execute(The Perl6 linter should complain about undeclared variables):
call ale#test#SetFilename('bar.pl6')
AssertEqual
\ [
\ {
\ 'lnum': '6',
\ 'text': 'Variable ''$tes'' is not declared. Did you mean any of these? $res $test ',
\ 'type': 'E',
\ 'col': '',
\ 'end_lnum': '',
\ 'code': 'X::Undeclared',
\ }
\ ],
\ ale_linters#perl6#perl6#Handle(bufnr(''), [
\ '{
\ "X::Undeclared" : {
\ "highexpect" : [ ],
\ "is-compile-time" : 1,
\ "modules" : [ ],
\ "column" : null,
\ "pos" : 18,
\ "symbol" : "$tes",
\ "filename" : "bar.pl6",
\ "what" : "Variable",
\ "pre" : "my $test = 0; say ",
\ "post" : "$tes",
\ "suggestions" : [
\ "$res",
\ "$test"
\ ],
\ "line" : 6,
\ "message" : "Variable ''$tes'' is not declared. Did you mean any of these?\n $res\n $test\n"
\ }
\ }'
\ ])
Execute(The Perl6 linter should complain about Comp::AdHoc errors):
call ale#test#SetFilename('bar.pl6')
AssertEqual
\ [
\ {
\ 'lnum': '3',
\ 'type': 'E',
\ 'text': 'is repr(...) trait needs a parameter',
\ 'col': '',
\ 'end_lnum': '',
\ 'code': 'X::Comp::AdHoc',
\ }
\ ],
\ ale_linters#perl6#perl6#Handle(bufnr(''), [
\ '{
\ "X::Comp::AdHoc" : {
\ "pre" : "class test is repr",
\ "message" : "is repr(...) trait needs a parameter",
\ "line" : 3,
\ "post" : " {}",
\ "is-compile-time" : true,
\ "pos" : 19,
\ "highexpect" : [ ],
\ "payload" : "is repr(...) trait needs a parameter",
\ "filename" : "bar.pl6",
\ "column" : null,
\ "modules" : [ ]
\ }
\ }'
\])
Execute(The Perl6 linter should be able to extract a line number from an error message):
call ale#test#SetFilename('bar.pl6')
AssertEqual
\ [
\ {
\ 'lnum': '3',
\ '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>',
\ 'col': '',
\ 'type': 'E',
\ 'end_lnum': '',
\ 'code': 'X::CompUnit::UnsatisfiedDependency',
\ }
\ ],
\ ale_linters#perl6#perl6#Handle(bufnr(''), [
\ '{
\ "X::CompUnit::UnsatisfiedDependency" : {
\ "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>",
\ "specification" : "Module::Does::not::exist"
\ }
\ }'
\ ])
Execute(The Perl6 linter should be able to differentiate between warnings and errors):
call ale#test#SetFilename('bar.pl6')
AssertEqual
\ [
\ {
\ 'lnum': '1',
\ 'col': '',
\ 'code': 'X::Syntax::Regex::Unterminated',
\ 'end_lnum': '',
\ 'type': 'E',
\ 'text': 'Regex not terminated.',
\ },
\ {
\ 'lnum': '1',
\ 'col': '',
\ 'code': 'X::Comp::AdHoc',
\ 'end_lnum': '',
\ 'type': 'W',
\ '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)',
\ }
\ ],
\ ale_linters#perl6#perl6#Handle(bufnr(''), [
\ '{
\ "X::Comp::Group" : {
\ "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)",
\ "panic" : "Unable to parse regex; couldn''t find final ''/''",
\ "sorrows" : [
\ {
\ "X::Syntax::Regex::Unterminated" : {
\ "highexpect" : [
\ "infix stopper"
\ ],
\ "pos" : 6,
\ "is-compile-time" : 1,
\ "modules" : [ ],
\ "post" : "<EOL>",
\ "message" : "Regex not terminated.",
\ "line" : 1,
\ "filename" : "bar.pl6",
\ "column" : null,
\ "pre" : "/win 3"
\ }
\ }
\ ],
\ "worries" : [
\ {
\ "X::Comp::AdHoc" : {
\ "filename" : "bar.pl6",
\ "line" : 1,
\ "column" : null,
\ "pre" : "/win",
\ "highexpect" : [ ],
\ "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)",
\ "post" : " 3",
\ "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)",
\ "modules" : [ ],
\ "is-compile-time" : true,
\ "pos" : 4
\ }
\ }
\ ]
\ }
\ }'
\])
Execute(The Perl6 linter should gracefully handle non-JSON messages):
call ale#test#SetFilename('bar.pl6')
AssertEqual
\ [
\ {
\ 'lnum': '1',
\ 'text': 'Received output in the default Perl6 error format. See :ALEDetail for details',
\ 'type': 'W',
\ 'detail': join([
\ 'Potential difficulties:',
\ ' Redeclaration of symbol ''$_''',
\ ' at /home/travis/perl6-error-fail/insanity-test.pl6:1',
\ ' ------> sub foo($_) {.say}; my $_<HERE> = 1; .&foo;',
\ ' 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)',
\ ' at /home/travis/perl6-error-fail/insanity-test.pl6:4',
\ ' ------> /win<HERE> 3/',
\ 'Syntax OK',], "\n")
\ }
\ ],
\ ale_linters#perl6#perl6#Handle(bufnr(''), [
\ 'Potential difficulties:',
\ ' Redeclaration of symbol ''$_''',
\ ' at /home/travis/perl6-error-fail/insanity-test.pl6:1',
\ ' ------> sub foo($_) {.say}; my $_<HERE> = 1; .&foo;',
\ ' 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)',
\ ' at /home/travis/perl6-error-fail/insanity-test.pl6:4',
\ ' ------> /win<HERE> 3/',
\ 'Syntax OK'
\ ])
Execute(The Perl6 linter should gracefully handle messages without a line number):
call ale#test#SetFilename('bar.pl6')
AssertEqual
\ [
\ {
\ 'lnum': '1',
\ 'end_lnum': '',
\ 'text': 'Cannot find method ''has_compile_time_value'' on object of type NQPMu',
\ 'type': 'E',
\ 'col' : '',
\ 'code': 'X::AdHoc',
\ }
\ ],
\ ale_linters#perl6#perl6#Handle(bufnr(''), [
\ '{',
\ '"X::AdHoc" : {',
\ '"message" : "Cannot find method ''has_compile_time_value'' on object of type NQPMu",',
\ '"payload" : "Cannot find method ''has_compile_time_value'' on object of type NQPMu"',
\ '}',
\ '}',
\ ])
Execute(The Perl6 linter should not include errors from a known separate file):
call ale#test#SetFilename('bar.pl6')
AssertEqual
\ [],
\ ale_linters#perl6#perl6#Handle(bufnr(''), [
\ '{
\ "X::Undeclared" : {
\ "highexpect" : [ ],
\ "is-compile-time" : 1,
\ "modules" : [ ],
\ "column" : null,
\ "pos" : 18,
\ "symbol" : "$tes",
\ "filename" : "foo.pl6",
\ "what" : "Variable",
\ "pre" : "my $test = 0; say ",
\ "post" : "$tes",
\ "suggestions" : [
\ "$res",
\ "$test"
\ ],
\ "line" : 6,
\ "message" : "Variable ''$tes'' is not declared. Did you mean any of these?\n $res\n $test\n"
\ }
\ }'
\ ])
Execute(The Perl6 linter should not ignore errors without a filename):
call ale#test#SetFilename('bar.pl6')
AssertEqual
\ [
\ {
\ 'lnum': '3',
\ 'end_lnum': '',
\ 'text': 'Cannot find method ''has_compile_time_value'' on object of type NQPMu',
\ 'type': 'E',
\ 'col' : '',
\ 'code': 'X::AdHoc',
\ }
\ ],
\ ale_linters#perl6#perl6#Handle(bufnr(''), [
\ '{',
\ '"X::AdHoc" : {',
\ '"line" : 3,',
\ '"message" : "Cannot find method ''has_compile_time_value'' on object of type NQPMu",',
\ '"payload" : "Cannot find method ''has_compile_time_value'' on object of type NQPMu"',
\ '}',
\ '}',
\ ])
|