1--TEST--
2Parse errors during token_get_all()
3--SKIPIF--
4<?php if (!extension_loaded("tokenizer")) print "skip"; ?>
5--FILE--
6<?php
7
8function test_parse_error($code) {
9    try {
10        var_dump(token_get_all($code, TOKEN_PARSE));
11    } catch (ParseError $e) {
12        echo $e->getMessage(), "\n";
13    }
14
15    foreach (token_get_all($code) as $token) {
16        if (is_array($token)) {
17            echo token_name($token[0]), " ($token[1])\n";
18        } else {
19            echo "$token\n";
20        }
21    }
22    echo "\n";
23}
24
25test_parse_error('<?php var_dump(078);');
26test_parse_error('<?php var_dump("\u{xyz}");');
27test_parse_error('<?php var_dump("\u{ffffff}");');
28test_parse_error('<?php var_dump(078 + 078);');
29
30?>
31--EXPECT--
32Invalid numeric literal
33T_OPEN_TAG (<?php )
34T_STRING (var_dump)
35(
36T_LNUMBER (078)
37)
38;
39
40Invalid UTF-8 codepoint escape sequence
41T_OPEN_TAG (<?php )
42T_STRING (var_dump)
43(
44T_CONSTANT_ENCAPSED_STRING ("\u{xyz}")
45)
46;
47
48Invalid UTF-8 codepoint escape sequence: Codepoint too large
49T_OPEN_TAG (<?php )
50T_STRING (var_dump)
51(
52T_CONSTANT_ENCAPSED_STRING ("\u{ffffff}")
53)
54;
55
56Invalid numeric literal
57T_OPEN_TAG (<?php )
58T_STRING (var_dump)
59(
60T_LNUMBER (078)
61T_WHITESPACE ( )
62+
63T_WHITESPACE ( )
64T_LNUMBER (078)
65)
66;
67