public function testReportsUsefulUnknownCharErrors()
{
$run = function ($num, $str, $expectedMessage) {
try {
$this->lexOne($str);
$this->fail('Expected exception not thrown in example: ' . $num);
} catch (SyntaxError $e) {
$this->assertEquals($expectedMessage, $e->getMessage(), "Test case {$num} failed");
}
};
$run(1, '..', "Syntax Error GraphQL (1:1) Cannot parse the unexpected character \".\".\n\n1: ..\n ^\n");
$run(2, '?', "Syntax Error GraphQL (1:1) Cannot parse the unexpected character \"?\".\n\n1: ?\n ^\n");
$unicode = json_decode('"\\u203B"');
$run(3, $unicode, "Syntax Error GraphQL (1:1) Cannot parse the unexpected character \"\\u203b\".\n\n1: {$unicode}\n ^\n");
$unicode = json_decode('"\\u200b"');
$run(4, $unicode, "Syntax Error GraphQL (1:1) Cannot parse the unexpected character \"\\u200b\".\n\n1: {$unicode}\n ^\n");
}