test_php_handler.vader
1 Before: 2 runtime ale_linters/php/php.vim 3 4 After: 5 call ale#linter#Reset() 6 7 Given (Some invalid lines of PHP): 8 [foo;] 9 class Foo { / } 10 $foo) 11 ['foo' 'bar'] 12 function count() {} 13 14 Execute(The php handler should calculate column numbers): 15 AssertEqual 16 \ [ 17 \ { 18 \ 'lnum': 1, 19 \ 'col': 5, 20 \ 'end_col': 5, 21 \ 'text': "syntax error, unexpected ';', expecting ']'", 22 \ }, 23 \ { 24 \ 'lnum': 2, 25 \ 'col': 13, 26 \ 'end_col': 13, 27 \ 'text': "syntax error, unexpected '/', expecting function (T_FUNCTION) or const (T_CONST)", 28 \ }, 29 \ { 30 \ 'lnum': 3, 31 \ 'col': 5, 32 \ 'end_col': 5, 33 \ 'text': "syntax error, unexpected ')'", 34 \ }, 35 \ { 36 \ 'lnum': 4, 37 \ 'col': 8, 38 \ 'end_col': 12, 39 \ 'text': "syntax error, unexpected ''bar'' (T_CONSTANT_ENCAPSED_STRING), expecting ']'", 40 \ }, 41 \ ], 42 \ ale_linters#php#php#Handle(347, [ 43 \ "This line should be ignored completely", 44 \ "Parse error: syntax error, unexpected ';', expecting ']' in - on line 1", 45 \ "Parse error: syntax error, unexpected '/', expecting function (T_FUNCTION) or const (T_CONST) in - on line 2", 46 \ "Parse error: syntax error, unexpected ')' in - on line 3", 47 \ "Parse error: syntax error, unexpected ''bar'' (T_CONSTANT_ENCAPSED_STRING), expecting ']' in - on line 4", 48 \ ]) 49 50 Execute (The php handler should ignore lines starting with 'PHP Parse error'): 51 AssertEqual 52 \ [], 53 \ ale_linters#php#php#Handle(347, [ 54 \ "PHP Parse error: syntax error, This line should be ignored completely in - on line 1", 55 \ ]) 56 57 Execute (The php handler should handle lines containing 'Standard input code'): 58 AssertEqual 59 \ [ 60 \ { 61 \ 'lnum': 47, 62 \ 'col': 0, 63 \ 'text': "Invalid numeric literal", 64 \ }, 65 \ ], 66 \ ale_linters#php#php#Handle(347, [ 67 \ "Parse error: Invalid numeric literal in Standard input code on line 47", 68 \ ]) 69 Execute (The php handler should parse lines without column indication): 70 AssertEqual 71 \ [ 72 \ { 73 \ 'lnum': 5, 74 \ 'col': 0, 75 \ 'text': "Cannot redeclare count()", 76 \ }, 77 \ { 78 \ 'lnum': 21, 79 \ 'col': 0, 80 \ 'text': "syntax error, unexpected end of file", 81 \ }, 82 \ { 83 \ 'lnum': 47, 84 \ 'col': 0, 85 \ 'text': "Invalid numeric literal", 86 \ }, 87 \ ], 88 \ ale_linters#php#php#Handle(347, [ 89 \ "This line should be ignored completely", 90 \ "Fatal error: Cannot redeclare count() in - on line 5", 91 \ "Parse error: syntax error, unexpected end of file in - on line 21", 92 \ "Parse error: Invalid numeric literal in - on line 47", 93 \ ])