1
0
mirror of https://github.com/php/php-src.git synced 2026-03-26 09:12:14 +01:00
Files
archived-php-src/ext/tokenizer/tests/parse_errors.phpt
Nikita Popov a8bf1c5d8f Throw ParseException from lexer
Primarily to avoid getting fatal errors from token_get_all().

Implemented using a magic E_ERROR token, which the lexer emits to
force a parser failure.
2015-04-02 16:31:17 +02:00

27 lines
649 B
PHP

--TEST--
Parse errors during token_get_all()
--SKIPIF--
<?php if (!extension_loaded("tokenizer")) print "skip"; ?>
--FILE--
<?php
function test_parse_error($code) {
try {
var_dump(token_get_all($code));
} catch (ParseException $e) {
echo $e->getMessage(), "\n";
}
}
test_parse_error('<?php var_dump(078);');
test_parse_error('<?php var_dump("\u{xyz}");');
test_parse_error('<?php var_dump("\u{ffffff}");');
test_parse_error('<?php var_dump(078 + 078);');
?>
--EXPECT--
Invalid numeric literal
Invalid UTF-8 codepoint escape sequence
Invalid UTF-8 codepoint escape sequence: Codepoint too large
Invalid numeric literal