Mercurial > hg > cmmr2012-drupal-site
comparison vendor/nikic/php-parser/test/updateTests.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children | a9cd425dd02b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
1 <?php | |
2 | |
3 namespace PhpParser; | |
4 | |
5 require __DIR__ . '/bootstrap.php'; | |
6 require __DIR__ . '/PhpParser/CodeTestParser.php'; | |
7 require __DIR__ . '/PhpParser/CodeParsingTest.php'; | |
8 | |
9 $dir = __DIR__ . '/code/parser'; | |
10 | |
11 $testParser = new CodeTestParser; | |
12 $codeParsingTest = new CodeParsingTest; | |
13 foreach (filesInDir($dir, 'test') as $fileName => $code) { | |
14 if (false !== strpos($code, '@@{')) { | |
15 // Skip tests with evaluate segments | |
16 continue; | |
17 } | |
18 | |
19 list($name, $tests) = $testParser->parseTest($code, 2); | |
20 $newTests = []; | |
21 foreach ($tests as list($modeLine, list($input, $expected))) { | |
22 $modes = null !== $modeLine ? array_fill_keys(explode(',', $modeLine), true) : []; | |
23 list($parser5, $parser7) = $codeParsingTest->createParsers($modes); | |
24 $output = isset($modes['php5']) | |
25 ? $codeParsingTest->getParseOutput($parser5, $input, $modes) | |
26 : $codeParsingTest->getParseOutput($parser7, $input, $modes); | |
27 $newTests[] = [$modeLine, [$input, $output]]; | |
28 } | |
29 | |
30 $newCode = $testParser->reconstructTest($name, $newTests); | |
31 file_put_contents($fileName, $newCode); | |
32 } |