X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fpsy%2Fpsysh%2Ftest%2FPsy%2FTest%2FCodeCleaner%2FCallTimePassByReferencePassTest.php;fp=vendor%2Fpsy%2Fpsysh%2Ftest%2FPsy%2FTest%2FCodeCleaner%2FCallTimePassByReferencePassTest.php;h=e4e338f71efcec6711769d76173737beb45d2e29;hp=0000000000000000000000000000000000000000;hb=eba34333e3c89f208d2f72fa91351ad019a71583;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae diff --git a/vendor/psy/psysh/test/Psy/Test/CodeCleaner/CallTimePassByReferencePassTest.php b/vendor/psy/psysh/test/Psy/Test/CodeCleaner/CallTimePassByReferencePassTest.php new file mode 100644 index 000000000..e4e338f71 --- /dev/null +++ b/vendor/psy/psysh/test/Psy/Test/CodeCleaner/CallTimePassByReferencePassTest.php @@ -0,0 +1,73 @@ +pass = new CallTimePassByReferencePass(); + $this->traverser = new NodeTraverser(); + $this->traverser->addVisitor($this->pass); + } + + /** + * @dataProvider invalidStatements + * @expectedException \Psy\Exception\FatalErrorException + */ + public function testProcessStatementFails($code) + { + if (version_compare(PHP_VERSION, '5.4', '<')) { + $this->markTestSkipped(); + } + + $stmts = $this->parse($code); + $this->traverser->traverse($stmts); + } + + public function invalidStatements() + { + return array( + array('f(&$arg)'), + array('$object->method($first, &$arg)'), + array('$closure($first, &$arg, $last)'), + array('A::b(&$arg)'), + ); + } + + /** + * @dataProvider validStatements + */ + public function testProcessStatementPasses($code) + { + $stmts = $this->parse($code); + $this->traverser->traverse($stmts); + } + + public function validStatements() + { + $data = array( + array('array(&$var)'), + array('$a = &$b'), + array('f(array(&$b))'), + ); + + if (version_compare(PHP_VERSION, '5.4', '<')) { + $data = array_merge($data, $this->invalidStatements()); + } + + return $data; + } +}