X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fnikic%2Fphp-parser%2Ftest%2FPhpParser%2FLexer%2FEmulativeTest.php;fp=vendor%2Fnikic%2Fphp-parser%2Ftest%2FPhpParser%2FLexer%2FEmulativeTest.php;h=533547ae4825d8f24558fcfdfca87837c978ff46;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hp=3a33ba820760ed02735fe316d305534b3ebbf853;hpb=74df008bdbb3a11eeea356744f39b802369bda3c;p=yaffs-website diff --git a/vendor/nikic/php-parser/test/PhpParser/Lexer/EmulativeTest.php b/vendor/nikic/php-parser/test/PhpParser/Lexer/EmulativeTest.php index 3a33ba820..533547ae4 100644 --- a/vendor/nikic/php-parser/test/PhpParser/Lexer/EmulativeTest.php +++ b/vendor/nikic/php-parser/test/PhpParser/Lexer/EmulativeTest.php @@ -2,6 +2,7 @@ namespace PhpParser\Lexer; +use PhpParser\ErrorHandler; use PhpParser\LexerTest; use PhpParser\Parser\Tokens; @@ -63,12 +64,11 @@ class EmulativeTest extends LexerTest $lexer = $this->getLexer(); $lexer->startLexing('assertSame($expectedTokenType, $lexer->getNextToken($text)); - $this->assertSame($expectedTokenText, $text); + $tokens = []; + while (0 !== $token = $lexer->getNextToken($text)) { + $tokens[] = [$token, $text]; } - $this->assertSame(0, $lexer->getNextToken()); + $this->assertSame($expectedTokens, $tokens); } /** @@ -85,6 +85,29 @@ class EmulativeTest extends LexerTest $this->assertSame(0, $lexer->getNextToken()); } + /** + * @dataProvider provideTestLexNewFeatures + */ + public function testErrorAfterEmulation($code) { + $errorHandler = new ErrorHandler\Collecting; + $lexer = $this->getLexer([]); + $lexer->startLexing('getErrors(); + $this->assertCount(1, $errors); + + $error = $errors[0]; + $this->assertSame('Unexpected null byte', $error->getRawMessage()); + + $attrs = $error->getAttributes(); + $expPos = strlen('assertSame($expPos, $attrs['startFilePos']); + $this->assertSame($expPos, $attrs['endFilePos']); + $this->assertSame($expLine, $attrs['startLine']); + $this->assertSame($expLine, $attrs['endLine']); + } + public function provideTestLexNewFeatures() { return [ ['yield from', [ @@ -128,6 +151,43 @@ class EmulativeTest extends LexerTest [Tokens::T_END_HEREDOC, 'NOWDOC'], [ord(';'), ';'], ]], + + // Flexible heredoc/nowdoc + ["<<