4 * This file is part of Psy Shell.
6 * (c) 2012-2017 Justin Hileman
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Psy\Test\CodeCleaner;
14 use PhpParser\NodeTraverser;
15 use Psy\CodeCleaner\FunctionContextPass;
17 class FunctionContextPassTest extends CodeCleanerTestCase
19 public function setUp()
21 $this->pass = new FunctionContextPass();
22 $this->traverser = new NodeTraverser();
23 $this->traverser->addVisitor($this->pass);
27 * @dataProvider validStatements
29 public function testProcessStatementPasses($code)
31 $stmts = $this->parse($code);
32 $this->traverser->traverse($stmts);
34 // @todo a better thing to assert here?
35 $this->assertTrue(true);
38 public function validStatements()
41 array('function foo() { yield; }'),
42 array('if (function(){ yield; })'),
47 * @dataProvider invalidYieldStatements
48 * @expectedException \Psy\Exception\FatalErrorException
50 public function testInvalidYield($code)
52 if (version_compare(PHP_VERSION, '5.4', '<')) {
53 $this->markTestSkipped();
56 $stmts = $this->parse($code);
57 $this->traverser->traverse($stmts);
60 public function invalidYieldStatements()