コード例 #1
-5
ファイル: test.php プロジェクト: nandychen/steward
/**
 * Main test
 *
 * @param $input
 * @param $expected
 */
function st_test($input, $expected)
{
    global $opts;
    $debug = false;
    if ($debug) {
        echo "=[ INPUT ]===\n" . $input . "\n";
        echo "=[ EXPECTED ]===\n" . $expected . "\n";
    }
    $jsbeautifier = new JSBeautifier();
    $result = $jsbeautifier->beautify($input, $opts);
    if ($expected != $result) {
        if (!$debug) {
            echo "=[ INPUT ]===\n" . $input . "\n";
            echo "=[ EXPECTED ]===\n" . $expected . "\n";
        }
        echo "=[ RESULT ]===\n" . $result . "\n=[ RESULT ]===\n";
        echo "Test did not pass!\n";
        for ($i = 0; $i < strlen($expected); $i++) {
            if (!isset($result[$i])) {
                echo "Result too short!\n";
                break;
            } elseif ($expected[$i] != $result[$i]) {
                //echo "Diff at position #$i!\n";
            }
        }
        die;
    }
}
コード例 #2
-9
function js_beautify($string, $options = null)
{
    $beautifier = new JSBeautifier();
    return $beautifier->beautify($string, $options);
}