4 * This file is part of Psy Shell.
6 * (c) 2012-2018 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\Command\TimeitCommand;
14 use PhpParser\NodeTraverser;
15 use Psy\Command\TimeitCommand\TimeitVisitor;
16 use Psy\Test\ParserTestCase;
18 class TimeitVisitorTest extends ParserTestCase
20 public function setUp()
22 $this->traverser = new NodeTraverser();
23 $this->traverser->addVisitor(new TimeitVisitor());
29 public function testProcess($from, $to)
31 $this->assertProcessesAs($from, $to);
34 public function codez()
36 $start = '\Psy\Command\TimeitCommand::markStart';
37 $end = '\Psy\Command\TimeitCommand::markEnd';
38 $noReturn = 'new \Psy\CodeCleaner\NoReturnValue()';
41 ['', "$end($start());"], // heh
42 ['a()', "$start(); $end(a());"],
43 ['$b()', "$start(); $end(\$b());"],
44 ['$c->d()', "$start(); $end(\$c->d());"],
45 ['e(); f()', "$start(); e(); $end(f());"],
46 ['function g() { return 1; }', "$start(); function g() {return 1;} $end($noReturn);"],
47 ['return 1', "$start(); return $end(1);"],
48 ['return 1; 2', "$start(); return $end(1); $end(2);"],
49 ['return 1; function h() {}', "$start(); return $end(1); function h() {} $end($noReturn);"],