<?php foreach (array('vendor/phpunit/phpunit/PHPUnitPHPUnit/Autoload.php', 'PHPUnit/Autoload.php', 'src/lightncandy.php') as $inc) { if (file_exists($inc)) { include_once $inc; break; } } genTestForClass('LightnCandy'); genTestForClass('LCRun3'); function genTestForClass($classname) { ob_start(); echo <<<VAR <?php /** * Generated by build/gen_test */ require_once('src/lightncandy.php'); class {$classname}Test extends PHPUnit_Framework_TestCase { VAR; $class = new ReflectionClass($classname); foreach ($class->getMethods() as $method) { if (preg_match_all('/@expect (.+) when input (.+)( after (.+))?/', $method->getDocComment(), $matched)) { echo <<<VAR /** * @covers {$classname}::{$method->name} */
<?php require __DIR__ . '/../vendor/autoload.php'; use LightnCandy\LightnCandy; genTestForClass('Compiler'); genTestForClass('Context'); genTestForClass('Exporter'); genTestForClass('Encoder'); genTestForClass('Expression'); genTestForClass('LightnCandy'); genTestForClass('Parser'); genTestForClass('Partial'); genTestForClass('Runtime'); genTestForClass('SafeString'); genTestForClass('Token'); genTestForClass('Validator'); function genTestForClass($classname) { ob_start(); echo <<<VAR <?php /** * Generated by build/gen_test */ use LightnCandy\\LightnCandy; use LightnCandy\\Runtime; use LightnCandy\\SafeString; require_once(__DIR__ . '/test_util.php'); class {$classname}Test extends PHPUnit_Framework_TestCase