1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2025-01-20 12:46:47 +01:00

Make tests compatible with PHP 7

When parsing on PHP 7 we will no longer be able to deal with
code that contains invalid octal literals. Currently we'll fatal,
after engine exceptions land we'll throw an exception instead.
This commit is contained in:
Nikita Popov 2015-02-26 16:26:29 +01:00
parent d600c60779
commit 91295a0790
3 changed files with 15 additions and 10 deletions

View File

@ -124,6 +124,19 @@ EOC;
$parser = new Parser($lexer);
$parser->parse('dummy');
}
public function testInvalidOctals() {
if (version_compare(PHP_VERSION, '7.0-dev', '>=')) {
$this->markTestSkipped('Cannot parse invalid octal numbers on PHP 7');
}
$parser = new Parser(new Lexer);
$stmts = $parser->parse('<?php 0787; 0177777777777777777777787;');
$this->assertInstanceof($stmts[0], 'PhpParser\Scalar\LNumber');
$this->assertInstanceof($stmts[1], 'PhpParser\Scalar\DNumber');
$this->assertSame(7, $stmts[0]->value);
$this->assertSame(0xFFFFFFFFFFFFFFFF, $stmts[0]->value);
}
}
class InvalidTokenLexer extends Lexer {

View File

@ -18,7 +18,6 @@ Different float syntaxes
18446744073709551615;
0xFFFFFFFFFFFFFFFF;
01777777777777777777777;
0177777777777777777777787;
0b1111111111111111111111111111111111111111111111111111111111111111;
-----
array(
@ -64,7 +63,4 @@ array(
13: Scalar_DNumber(
value: @@{ 0xFFFFFFFFFFFFFFFF }@@
)
14: Scalar_DNumber(
value: @@{ 0xFFFFFFFFFFFFFFFF }@@
)
)

View File

@ -10,7 +10,6 @@ Different integer syntaxes
0xfff;
0XfFf;
0777;
0787;
0b111000111000;
-----
array(
@ -39,9 +38,6 @@ array(
value: 511
)
8: Scalar_LNumber(
value: 7
)
9: Scalar_LNumber(
value: 3640
)
)