Пример #1
0
function st_test($input, $expected)
{
    global $opts;
    $debug = false;
    if ($debug) {
        echo "=[ INPUT ]===\n" . $input . "\n";
        echo "=[ EXPECTED ]===\n" . $expected . "\n";
    }
    $result = js_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
0
 /**
  * Beautify models file
  *
  * @param string $str The contents of the models file
  * @return string
  */
 protected function _beautify($str)
 {
     include_once GARP_APPLICATION_PATH . '/../library/Garp/3rdParty/JsBeautifier/jsbeautifier.php';
     return js_beautify($str);
 }
Пример #3
0
                    $esc = $input[$pos] == '\\';
                } else {
                    $esc = false;
                }
                $pos += 1;
                if ($pos >= $input_length) {
                    break;
                }
            }
        }
        $pos += 1;
        if ($last_type == TK_END_COMMAND) {
            nl();
        }
        return array($sep . $c . $sep, TK_STRING);
    }
    if (in_array($c, $punct)) {
        while (in_array($c . $input[$pos], $punct)) {
            $c .= $input[$pos];
            $pos += 1;
            if ($pos >= $input_length) {
                break;
            }
        }
        return array($c, TK_OPERATOR);
    }
    return array($c, TK_UNKNOWN);
}
$BBEditInput = file_get_contents("php://stdin") or die($php_errormsg);
print js_beautify($BBEditInput);
Пример #4
0
 protected function _showJsBaseModel($modelId)
 {
     $modelSet = $this->getModelSet();
     if (array_key_exists($modelId, $modelSet)) {
         $model = $modelSet[$modelId];
         $minBaseModel = $model->renderJsBaseModel($modelSet);
         include_once GARP_APPLICATION_PATH . '/../library/Garp/3rdParty/JsBeautifier/jsbeautifier.php';
         echo js_beautify($minBaseModel) . "\n";
     } else {
         Garp_Cli::errorOut("I don't know the model {$modelId}.");
         Garp_Cli::lineOut("I do know " . implode(", ", array_keys((array) $modelSet)) . '.');
     }
 }