mirror of
https://github.com/nikic/PHP-Parser.git
synced 2025-03-13 19:00:01 +01:00
Split up pretty printer test in stmt/expr
The list was getting unweildly. Also improve error message when parsing fails in pretty printer test and extend some tests.
This commit is contained in:
parent
2b9c5a62cb
commit
e4b837e0c4
@ -23,14 +23,18 @@ class PrettyPrinterTest extends CodeTestAbstract
|
||||
$output5 = canonicalize($prettyPrinter->$method($parser5->parse($code)));
|
||||
} catch (Error $e) {
|
||||
$output5 = null;
|
||||
$this->assertEquals('php7', $version);
|
||||
if ('php7' !== $version) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$output7 = canonicalize($prettyPrinter->$method($parser7->parse($code)));
|
||||
} catch (Error $e) {
|
||||
$output7 = null;
|
||||
$this->assertEquals('php5', $version);
|
||||
if ('php5' !== $version) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
if ('php5' === $version) {
|
||||
|
@ -5,11 +5,8 @@ For loop
|
||||
// "classical" loop
|
||||
for ($i = 0; $i < $c; ++$i) {}
|
||||
|
||||
// "classical" loop + multiple init
|
||||
for ($i = 0, $j = 0; $i < $c; ++$i) {}
|
||||
|
||||
// multiple expressions
|
||||
for (;$a,$b;) {}
|
||||
for ($a, $b; $c, $d; $e, $f) {}
|
||||
|
||||
// infinite loop
|
||||
for (;;) {}
|
||||
@ -52,38 +49,27 @@ array(
|
||||
)
|
||||
1: Stmt_For(
|
||||
init: array(
|
||||
0: Expr_Assign(
|
||||
var: Expr_Variable(
|
||||
name: i
|
||||
)
|
||||
expr: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
0: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
1: Expr_Assign(
|
||||
var: Expr_Variable(
|
||||
name: j
|
||||
)
|
||||
expr: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
1: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
cond: array(
|
||||
0: Expr_BinaryOp_Smaller(
|
||||
left: Expr_Variable(
|
||||
name: i
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
0: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
1: Expr_Variable(
|
||||
name: d
|
||||
)
|
||||
)
|
||||
loop: array(
|
||||
0: Expr_PreInc(
|
||||
var: Expr_Variable(
|
||||
name: i
|
||||
)
|
||||
0: Expr_Variable(
|
||||
name: e
|
||||
)
|
||||
1: Expr_Variable(
|
||||
name: f
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
@ -93,12 +79,6 @@ array(
|
||||
init: array(
|
||||
)
|
||||
cond: array(
|
||||
0: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
1: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
loop: array(
|
||||
)
|
||||
@ -115,14 +95,4 @@ array(
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
4: Stmt_For(
|
||||
init: array(
|
||||
)
|
||||
cond: array(
|
||||
)
|
||||
loop: array(
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
@ -1,9 +0,0 @@
|
||||
continue
|
||||
-----
|
||||
<?php
|
||||
|
||||
continue;
|
||||
continue 2;
|
||||
-----
|
||||
continue;
|
||||
continue 2;
|
13
test/code/prettyPrinter/stmt/break_continue.test
Normal file
13
test/code/prettyPrinter/stmt/break_continue.test
Normal file
@ -0,0 +1,13 @@
|
||||
break/continue
|
||||
-----
|
||||
<?php
|
||||
|
||||
continue;
|
||||
continue 2;
|
||||
break;
|
||||
break 2;
|
||||
-----
|
||||
continue;
|
||||
continue 2;
|
||||
break;
|
||||
break 2;
|
@ -2,6 +2,8 @@ goto
|
||||
-----
|
||||
<?php
|
||||
|
||||
marker:
|
||||
goto marker;
|
||||
-----
|
||||
marker:
|
||||
goto marker;
|
@ -8,9 +8,20 @@ if ($expr) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
if ($expr) {
|
||||
} else if ($expr2) {
|
||||
} else {
|
||||
}
|
||||
-----
|
||||
if ($expr) {
|
||||
} elseif ($expr2) {
|
||||
} else {
|
||||
}
|
||||
if ($expr) {
|
||||
} else {
|
||||
if ($expr2) {
|
||||
} else {
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user