Mercurial > hg > isophonics-drupal-site
comparison vendor/psy/psysh/test/Psy/Test/CodeCleaner/FunctionContextPassTest.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 7a779792577d |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 /* | |
4 * This file is part of Psy Shell. | |
5 * | |
6 * (c) 2012-2017 Justin Hileman | |
7 * | |
8 * For the full copyright and license information, please view the LICENSE | |
9 * file that was distributed with this source code. | |
10 */ | |
11 | |
12 namespace Psy\Test\CodeCleaner; | |
13 | |
14 use PhpParser\NodeTraverser; | |
15 use Psy\CodeCleaner\FunctionContextPass; | |
16 | |
17 class FunctionContextPassTest extends CodeCleanerTestCase | |
18 { | |
19 public function setUp() | |
20 { | |
21 $this->pass = new FunctionContextPass(); | |
22 $this->traverser = new NodeTraverser(); | |
23 $this->traverser->addVisitor($this->pass); | |
24 } | |
25 | |
26 /** | |
27 * @dataProvider validStatements | |
28 */ | |
29 public function testProcessStatementPasses($code) | |
30 { | |
31 $stmts = $this->parse($code); | |
32 $this->traverser->traverse($stmts); | |
33 } | |
34 | |
35 public function validStatements() | |
36 { | |
37 return array( | |
38 array('function foo() { yield; }'), | |
39 array('if (function(){ yield; })'), | |
40 ); | |
41 } | |
42 | |
43 /** | |
44 * @dataProvider invalidYieldStatements | |
45 * @expectedException \Psy\Exception\FatalErrorException | |
46 */ | |
47 public function testInvalidYield($code) | |
48 { | |
49 if (version_compare(PHP_VERSION, '5.4', '<')) { | |
50 $this->markTestSkipped(); | |
51 } | |
52 | |
53 $stmts = $this->parse($code); | |
54 $this->traverser->traverse($stmts); | |
55 } | |
56 | |
57 public function invalidYieldStatements() | |
58 { | |
59 return array( | |
60 array('yield'), | |
61 array('if (yield)'), | |
62 ); | |
63 } | |
64 } |