Example #1
0
 private function assertParsesAs($given, $expected)
 {
     $parser = new Scheme_Parser();
     if ($parser->parse($given)->toString() != $expected) {
         $s = $parser->parse($given)->toString();
         throw new Exception("ERROR: `{$given}`   ->   `{$s}`   (expected `{$expected}`)\n");
     }
 }
Example #2
0
 private function evalCode($code, array $envVars = array())
 {
     $parser = new Scheme_Parser($code);
     $expr = $parser->parse($code);
     $env = $this->rootEnv->createChildEnv();
     $env->bindAll($envVars);
     return $this->interp->evaluate($env, $expr);
 }
Example #3
0
 private function runTestFile($file)
 {
     $code = file_get_contents($file);
     $testName = basename($file, '.test.ss');
     $parser = new Scheme_Parser();
     $interpreter = new Scheme_Interpreter();
     $rootEnv = $interpreter->createEnv();
     $this->bindLibs($rootEnv);
     try {
         $stmts = $parser->parseToplevelStatements($code);
         foreach ($stmts as $stmt) {
             $interpreter->evaluate($rootEnv, $stmt);
         }
     } catch (Exception $ex) {
         $this->reporter->addFailure('TestRunner_Scheme', $testName, $ex);
     }
     if (!isset($ex)) {
         $this->reporter->addSuccess('TestRunner_Scheme', $testName);
     }
 }