mirror of
https://github.com/danog/PHP-Parser.git
synced 2024-11-26 20:04:48 +01:00
Pretty printer test coverage
Our output for yield / yield from is currently not very nice, but also not easy to change.
This commit is contained in:
parent
1fe8f09caa
commit
a73aa7eec1
29
test/code/prettyPrinter/expr/intrinsics.test
Normal file
29
test/code/prettyPrinter/expr/intrinsics.test
Normal file
@ -0,0 +1,29 @@
|
||||
isset, empty, unset, exit, die, clone, eval
|
||||
-----
|
||||
<?php
|
||||
|
||||
isset($a, $a[$b]);
|
||||
empty($a);
|
||||
empty('foo');
|
||||
unset($a, $a[$b]);
|
||||
exit;
|
||||
exit();
|
||||
exit(1);
|
||||
die;
|
||||
die();
|
||||
die("foo");
|
||||
clone $foo;
|
||||
eval('str');
|
||||
-----
|
||||
isset($a, $a[$b]);
|
||||
empty($a);
|
||||
empty('foo');
|
||||
unset($a, $a[$b]);
|
||||
die;
|
||||
die;
|
||||
die(1);
|
||||
die;
|
||||
die;
|
||||
die('foo');
|
||||
clone $foo;
|
||||
eval('str');
|
@ -81,6 +81,12 @@ b';
|
||||
'a
|
||||
b';
|
||||
}
|
||||
|
||||
// shell exec (similar to double quoted string)
|
||||
`foo`;
|
||||
`foo$a`;
|
||||
`foo{$a}bar`;
|
||||
`\`\'\"`;
|
||||
-----
|
||||
// magic constants
|
||||
__LINE__;
|
||||
@ -153,3 +159,8 @@ b';
|
||||
'a
|
||||
b';
|
||||
}
|
||||
// shell exec (similar to double quoted string)
|
||||
`foo`;
|
||||
`foo{$a}`;
|
||||
`foo{$a}bar`;
|
||||
`\`\\'\\"`;
|
44
test/code/prettyPrinter/expr/yield.test
Normal file
44
test/code/prettyPrinter/expr/yield.test
Normal file
@ -0,0 +1,44 @@
|
||||
Yield
|
||||
-----
|
||||
<?php
|
||||
|
||||
function gen()
|
||||
{
|
||||
yield;
|
||||
yield $a;
|
||||
yield $a => $b;
|
||||
$a = yield;
|
||||
$a = (yield $b);
|
||||
$a = (yield $b => $c);
|
||||
}
|
||||
// TODO Get rid of parens for cases 2 and 3
|
||||
-----
|
||||
function gen()
|
||||
{
|
||||
yield;
|
||||
(yield $a);
|
||||
(yield $a => $b);
|
||||
$a = yield;
|
||||
$a = (yield $b);
|
||||
$a = (yield $b => $c);
|
||||
}
|
||||
-----
|
||||
<?php
|
||||
|
||||
function gen()
|
||||
{
|
||||
$a = yield $b;
|
||||
$a = yield $b => $c;
|
||||
yield from $a;
|
||||
$a = yield from $b;
|
||||
}
|
||||
// TODO Get rid of parens for last case
|
||||
-----
|
||||
!!php7
|
||||
function gen()
|
||||
{
|
||||
$a = (yield $b);
|
||||
$a = (yield $b => $c);
|
||||
yield from $a;
|
||||
$a = (yield from $b);
|
||||
}
|
@ -8,4 +8,9 @@ echo 'Bar Foo';
|
||||
<?php
|
||||
|
||||
echo 'Foo Bar';
|
||||
echo 'Bar Foo';
|
||||
echo 'Bar Foo';
|
||||
-----
|
||||
<?php
|
||||
// avoid trim
|
||||
-----
|
||||
<?php
|
@ -2,7 +2,7 @@ Class
|
||||
-----
|
||||
<?php
|
||||
|
||||
class Foo
|
||||
class Foo extends Bar implements ABC, \DEF, namespace\GHI
|
||||
{
|
||||
var $a = 'foo';
|
||||
private $b = 'bar';
|
||||
@ -17,8 +17,15 @@ class Foo
|
||||
public function foo() {}
|
||||
abstract static function bar() {}
|
||||
}
|
||||
|
||||
trait Bar
|
||||
{
|
||||
function test()
|
||||
{
|
||||
}
|
||||
}
|
||||
-----
|
||||
class Foo
|
||||
class Foo extends Bar implements ABC, \DEF, namespace\GHI
|
||||
{
|
||||
var $a = 'foo';
|
||||
private $b = 'bar';
|
||||
@ -37,4 +44,10 @@ class Foo
|
||||
static abstract function bar()
|
||||
{
|
||||
}
|
||||
}
|
||||
trait Bar
|
||||
{
|
||||
function test()
|
||||
{
|
||||
}
|
||||
}
|
11
test/code/prettyPrinter/stmt/const.test
Normal file
11
test/code/prettyPrinter/stmt/const.test
Normal file
@ -0,0 +1,11 @@
|
||||
Constant declarations
|
||||
-----
|
||||
<?php
|
||||
|
||||
const FOO = 'BAR';
|
||||
const FOO = 1 + 1;
|
||||
const FOO = BAR, BAR = FOO;
|
||||
-----
|
||||
const FOO = 'BAR';
|
||||
const FOO = 1 + 1;
|
||||
const FOO = BAR, BAR = FOO;
|
11
test/code/prettyPrinter/stmt/global_static_variables.test
Normal file
11
test/code/prettyPrinter/stmt/global_static_variables.test
Normal file
@ -0,0 +1,11 @@
|
||||
Global and static variables
|
||||
-----
|
||||
<?php
|
||||
|
||||
global $a, $$a, ${$a[$a]};
|
||||
static $a, $b;
|
||||
static $a = 'foo', $b = 'bar';
|
||||
-----
|
||||
global $a, ${$a}, ${$a[$a]};
|
||||
static $a, $b;
|
||||
static $a = 'foo', $b = 'bar';
|
Loading…
Reference in New Issue
Block a user