full() public static méthode

public static full ( )
Exemple #1
0
function balrog_front_controller($baseDir)
{
    $environment = Lisphp_Environment::full();
    $scope = new Lisphp_Scope($environment);
    $scope['require'] = new Lisphp_Runtime_PHPFunction(function ($file) use($scope) {
        $program = Lisphp_Program::load(__DIR__ . '/' . $file . '.lisphp');
        return $program->execute($scope);
    });
    $scope['base-dir'] = $baseDir;
    $filename = __DIR__ . '/front-controller.lisphp';
    $program = Lisphp_Program::load($filename);
    $program->execute($scope);
}
Exemple #2
0
 public function testFromFile()
 {
     $testFiles = glob(__DIR__ . '/Functional/*.lisphp');
     foreach ($testFiles as $file) {
         $this->result = '';
         $program = Lisphp_Program::load($file);
         $scope = Lisphp_Environment::full();
         $scope['echo'] = new Lisphp_Runtime_PHPFunction(array($this, 'displayStrings'));
         $program->execute($scope);
         $expected = file_get_contents(preg_replace('/\\.lisphp$/', '.out', $file));
         $this->assertSame(trim($expected), trim($this->result));
     }
 }
 function testFull()
 {
     $scope = Lisphp_Environment::full();
     $this->testSandbox($scope);
     $this->assertType('Lisphp_Runtime_Use', $scope['use']);
     $this->assertType('Lisphp_Runtime_From', $scope['from']);
     $this->assertEquals($_ENV, $scope['*env*']);
     $this->assertEquals($_SERVER, $scope['*server*']);
 }
Exemple #4
0
<?php

require dirname(__FILE__) . '/Lisphp.php';
$options = getopt('v', array('verbose'));
function displayStrings()
{
    global $result;
    $args = func_get_args();
    $result .= join('', array_map('strval', $args));
}
$testFiles = glob(dirname(__FILE__) . '/tests/*.lisphp');
$fails = array();
foreach ($testFiles as $file) {
    $program = Lisphp_Program::load($file);
    $result = '';
    $scope = Lisphp_Environment::full();
    $scope['echo'] = new Lisphp_Runtime_PHPFunction('displayStrings');
    $program->execute($scope);
    $expected = file_get_contents(preg_replace('/\\.lisphp$/', '.out', $file));
    if (trim($result) == trim($expected)) {
        echo '.';
    } else {
        echo 'F';
        $fails[$file] = $result;
    }
}
if ($fails) {
    echo "\nFailed: ";
} else {
    echo "\nOK ";
}
Exemple #5
0
    echo $lines[$e->getLisphpLine() - 1], "\n";
    echo str_repeat(' ', $e->getLisphpColumn() - 1), "^\n";
}
$options = getopt('hvsc:');
if (isset($options['h']) || isset($options['v'])) {
    echo 'Lisphp ' . LISPHP_VERSION . "\n";
    if (isset($options['v'])) {
        echo 'PHP-', PHP_VERSION, "\n", php_uname(), "\n";
    }
    if (isset($options['h'])) {
        echo "Usage: {$_SERVER['argv'][0]} [options] <file>\n\n";
        echo Lisphp_usage(), "\n";
    }
    exit;
}
$environment = isset($options['s']) ? Lisphp_Environment::sandbox() : Lisphp_Environment::full();
$scope = new Lisphp_Scope($environment);
$scope['echo'] = new Lisphp_Runtime_PHPFunction(create_function('', '
    $args = func_get_args();
    foreach ($args as $arg) echo $arg;
'));
class Lisphp_EnterREPL extends Exception
{
}
try {
    $file = end($_SERVER['argv']);
    if (isset($options['c'])) {
        $program = new Lisphp_Program($options['c']);
    } else {
        if (count($_SERVER['argv']) > 1 && $file != '-s') {
            $program = Lisphp_Program::load($file);