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"); } }
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); }
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); } }