예제 #1
0
 function homogenize_output($output, $bundle)
 {
     return homogenize_all($output, $bundle->subject);
 }
예제 #2
0
function run_with_phc($program, $filename)
{
    global $opt_pass, $opt_main_command;
    # Compile and run
    mydebug(2, "Getting compiled phc output");
    $command = "src/phc --read-xml={$opt_pass} -e {$opt_main_command}";
    list($out, $err, $exit) = myrun($command, $program);
    if ($out == "Timeout") {
        mydebug(1, "Timed out");
        return false;
    }
    $out = homogenize_all($out, $filename);
    return array($out, $err, $exit);
}
        }
    }
    foreach ($unary_ops as $u) {
        test("{$u} {$s1}");
    }
}
// Create test files
$good = join("\n", $good);
$good = "<?php\n{$good}\n?>";
$filename = "test/subjects/parsing/constant_folding.php";
file_put_contents($filename, $good);
$i = 0;
foreach ($bad as $b) {
    list($string, $out, $err, $exit) = $b;
    $out = trim($out);
    $out = homogenize_all($out, $filename);
    $out = convert_to_phc_annotation($out);
    // make an error template
    $string = "<?php\n" . "var_dump ({$string}); // { {$out} }\n" . "?>";
    // error or warning
    if ($exit) {
        file_put_contents("test/subjects/errors/constant_folding{$i}.php", $string);
    } else {
        file_put_contents("test/subjects/warnings/constant_folding{$i}.php", $string);
    }
    $i++;
}
function test($str)
{
    list($out, $err, $exit) = complete_exec("echo '<?php \$x = {$str} ?>' | php");
    if ($exit || $out) {