diff --git a/test/PhpParser/ParserTest.php b/test/PhpParser/ParserTest.php index 2839f42..8537594 100644 --- a/test/PhpParser/ParserTest.php +++ b/test/PhpParser/ParserTest.php @@ -114,4 +114,21 @@ EOC; 'endTokenPos' => 18, ), $var->getAttributes()); } -} \ No newline at end of file + + /** + * @expectedException \RangeException + * @expectedExceptionMessage The lexer returned an invalid token (id=999, value=foobar) + */ + public function testInvalidToken() { + $lexer = new InvalidTokenLexer; + $parser = new Parser($lexer); + $parser->parse('dummy'); + } +} + +class InvalidTokenLexer extends Lexer { + public function getNextToken(&$value = null, &$startAttributes = null, &$endAttributes = null) { + $value = 'foobar'; + return 999; + } +}