1
0
Fork 0

Fix ParseErrorTests

pull/357/head
roblou 2017-05-19 10:55:22 -07:00
parent f2e6e3aa66
commit fc3e8ef349
1 changed files with 74 additions and 25 deletions

View File

@ -64,7 +64,55 @@ class ParseErrorsTest extends TestCase
'range' => [
'start' => [
'line' => 2,
'character' => 10
'character' => 9
],
'end' => [
'line' => 2,
'character' => 9
]
],
'severity' => DiagnosticSeverity::ERROR,
'code' => null,
'source' => 'php',
'message' => "'Name' expected."
],
[
'range' => [
'start' => [
'line' => 2,
'character' => 9
],
'end' => [
'line' => 2,
'character' => 9
]
],
'severity' => DiagnosticSeverity::ERROR,
'code' => null,
'source' => 'php',
'message' => "'{' expected."
],
[
'range' => [
'start' => [
'line' => 2,
'character' => 9
],
'end' => [
'line' => 2,
'character' => 9
]
],
'severity' => DiagnosticSeverity::ERROR,
'code' => null,
'source' => 'php',
'message' => "'}' expected."
],
[
'range' => [
'start' => [
'line' => 2,
'character' => 15
],
'end' => [
'line' => 2,
@ -74,32 +122,33 @@ class ParseErrorsTest extends TestCase
'severity' => DiagnosticSeverity::ERROR,
'code' => null,
'source' => 'php',
'message' => "Syntax error, unexpected T_CLASS, expecting T_STRING"
'message' => "'Name' expected."
]]
], json_decode(json_encode($this->args), true));
}
public function testParseErrorsWithOnlyStartLine()
{
$this->openFile(__DIR__ . '/../../../fixtures/namespace_not_first.php');
$this->assertEquals([
'whatever',
[[
'range' => [
'start' => [
'line' => 4,
'character' => 0
],
'end' => [
'line' => 4,
'character' => 0
]
],
'severity' => DiagnosticSeverity::ERROR,
'code' => null,
'source' => 'php',
'message' => "Namespace declaration statement has to be the very first statement in the script"
]]
], json_decode(json_encode($this->args), true));
}
// This diagnostic not yet implemented in tolerant-php-parser
// public function testParseErrorsWithOnlyStartLine()
// {
// $this->openFile(__DIR__ . '/../../../fixtures/namespace_not_first.php');
// $this->assertEquals([
// 'whatever',
// [[
// 'range' => [
// 'start' => [
// 'line' => 4,
// 'character' => 0
// ],
// 'end' => [
// 'line' => 4,
// 'character' => 0
// ]
// ],
// 'severity' => DiagnosticSeverity::ERROR,
// 'code' => null,
// 'source' => 'php',
// 'message' => "Namespace declaration statement has to be the very first statement in the script"
// ]]
// ], json_decode(json_encode($this->args), true));
// }
}