当前位置: 首页>>代码示例>>PHP>>正文


PHP countBytes函数代码示例

本文整理汇总了PHP中countBytes函数的典型用法代码示例。如果您正苦于以下问题:PHP countBytes函数的具体用法?PHP countBytes怎么用?PHP countBytes使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了countBytes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_Minify_JS_ClosureCompiler

function test_Minify_JS_ClosureCompiler()
{
    global $thisDir;
    $src = "\n(function (window, undefined){\n    function addOne(input) {\n        return 1 + input;\n    }\n    window.addOne = addOne;\n    window.undefined = undefined;\n})(window);\n    ";
    $minExpected = "(function(a,b){a.addOne=function(a){return 1+a};a.undefined=b})(window);";
    $minOutput = Minify_JS_ClosureCompiler::minify($src);
    if (false !== strpos($minOutput, 'Error(22): Too many compiles')) {
        echo "!NOTE: Too many recent calls to Closure Compiler API to test.\n";
        return;
    }
    $passed = assertTrue($minExpected == $minOutput, 'Minify_JS_ClosureCompiler : Overall');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n";
        echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n";
        echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n";
    }
    $src = "function blah({ return 'blah';} ";
    $exc = null;
    try {
        $minOutput = Minify_JS_ClosureCompiler::minify($src);
    } catch (Exception $e) {
        $exc = $e;
    }
    $passed = assertTrue($exc instanceof Minify_JS_ClosureCompiler_Exception, 'Minify_JS_ClosureCompiler : Throws Minify_JS_ClosureCompiler_Exception');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Message: " . var_export($exc->getMessage(), 1) . "\n\n\n";
    }
}
开发者ID:Bhaavya,项目名称:OpenLorenz,代码行数:28,代码来源:test_Minify_JS_ClosureCompiler.php

示例2: test_HTML

function test_HTML()
{
    global $thisDir;
    $src = file_get_contents($thisDir . '/_test_files/html/before.html');
    $minExpected = file_get_contents($thisDir . '/_test_files/html/before.min.html');
    $time = microtime(true);
    $minOutput = Minify_HTML::minify($src, array('cssMinifier' => array('Minify_CSS', 'minify'), 'jsMinifier' => array('JSMin', 'minify')));
    $time = microtime(true) - $time;
    $passed = assertTrue($minExpected === $minOutput, 'Minify_HTML');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        if ($passed) {
            echo "\n---Source: ", countBytes($src), " bytes\n", "---Output: ", countBytes($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n\n";
        } else {
            echo "\n---Output: ", countBytes($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n", "---Expected: ", countBytes($minExpected), " bytes\n\n{$minExpected}\n\n", "---Source: ", countBytes($src), " bytes\n\n{$src}\n\n\n";
        }
    }
    $src = file_get_contents($thisDir . '/_test_files/html/before2.html');
    $minExpected = file_get_contents($thisDir . '/_test_files/html/before2.min.html');
    $time = microtime(true);
    $minOutput = Minify_HTML::minify($src, array('cssMinifier' => array('Minify_CSS', 'minify'), 'jsMinifier' => array('JSMin', 'minify')));
    $time = microtime(true) - $time;
    $passed = assertTrue($minExpected === $minOutput, 'Minify_HTML');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        if ($passed) {
            echo "\n---Source: ", countBytes($src), " bytes\n", "---Output: ", countBytes($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n\n";
        } else {
            echo "\n---Output: ", countBytes($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n", "---Expected: ", countBytes($minExpected), " bytes\n\n{$minExpected}\n\n", "---Source: ", countBytes($src), " bytes\n\n{$src}\n\n\n";
        }
    }
}
开发者ID:Bhaavya,项目名称:OpenLorenz,代码行数:30,代码来源:test_Minify_HTML.php

示例3: test_JSMinPlus

function test_JSMinPlus()
{
    global $thisDir;
    $src = file_get_contents($thisDir . '/_test_files/js/condcomm.js');
    $minExpected = file_get_contents($thisDir . '/_test_files/js/condcomm.min_plus.js');
    $minOutput = JSMinPlus::minify($src);
    $passed = assertTrue($minExpected == $minOutput, 'JSMinPlus : Conditional Comments');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n";
        echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n";
        echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n";
    }
    return;
    $src = file_get_contents($thisDir . '/_test_files/js/before.js');
    $minExpected = file_get_contents($thisDir . '/_test_files/js/before.min_plus.js');
    $minOutput = JSMinPlus::minify($src);
    $passed = assertTrue($minExpected == $minOutput, 'JSMinPlus : Overall');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n";
        echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n";
        echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n";
    }
    $src = file_get_contents($thisDir . '/_test_files/js/issue74.js');
    $minExpected = file_get_contents($thisDir . '/_test_files/js/issue74.min_plus.js');
    $minOutput = JSMinPlus::minify($src);
    $passed = assertTrue($minExpected == $minOutput, 'JSMinPlus : Quotes in RegExp literals (Issue 74)');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n";
        echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n";
        echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n";
    }
}
开发者ID:awwthentic1234,项目名称:hey,代码行数:32,代码来源:test_JSMinPlus.php

示例4: test_Minify_Cache_File

function test_Minify_Cache_File()
{
    $data = str_repeat(md5(time()) . 'í', 100);
    // 3400 bytes in UTF-8
    $id = 'Minify_test_cache_noLock';
    $prefix = 'Minify_Cache_File : ';
    $cache = new Minify_Cache_File();
    echo "NOTE: Minify_Cache_File : path is set to: '" . $cache->getPath() . "'.\n";
    assertTrue(true === $cache->store($id, $data), $prefix . 'store');
    assertTrue(countBytes($data) === $cache->getSize($id), $prefix . 'getSize');
    assertTrue(true === $cache->isValid($id, $_SERVER['REQUEST_TIME'] - 10), $prefix . 'isValid');
    ob_start();
    $cache->display($id);
    $displayed = ob_get_contents();
    ob_end_clean();
    assertTrue($data === $displayed, $prefix . 'display');
    assertTrue($data === $cache->fetch($id), $prefix . 'fetch');
    // test with locks
    $id = 'Minify_test_cache_withLock';
    $cache = new Minify_Cache_File('', true);
    assertTrue(true === $cache->store($id, $data), $prefix . 'store w/ lock');
    assertTrue(countBytes($data) === $cache->getSize($id), $prefix . 'getSize');
    assertTrue(true === $cache->isValid($id, $_SERVER['REQUEST_TIME'] - 10), $prefix . 'isValid');
    ob_start();
    $cache->display($id);
    $displayed = ob_get_contents();
    ob_end_clean();
    assertTrue($data === $displayed, $prefix . 'display w/ lock');
    assertTrue($data === $cache->fetch($id), $prefix . 'fetch w/ lock');
}
开发者ID:awwthentic1234,项目名称:hey,代码行数:30,代码来源:test_Minify_Cache_File.php

示例5: test_Minify_YuiCSS

function test_Minify_YuiCSS()
{
    if (!is_file(MINIFY_TESTS_YUICOMPRESSOR_JAR_FILE)) {
        echo "      Minify_YUICompressor : To test this, install the .jar file and customize the constant in:\n";
        echo "                             " . __FILE__ . "\n";
        return;
    }
    Minify_YUICompressor::$jarFile = MINIFY_TESTS_YUICOMPRESSOR_JAR_FILE;
    Minify_YUICompressor::$tempDir = sys_get_temp_dir();
    $src = "/* stack overflow test */\n    div.image {\n      width:            100px;\n      height:           100px;\n      background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAALCAYAAABGbhwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo1RDg4RDYwQzU2N0ExMUUyOUNCMEY5NzdDNzlGNzg3MSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDo1RDg4RDYwRDU2N0ExMUUyOUNCMEY5NzdDNzlGNzg3MSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkM0RjRBMkZGNTY3NzExRTI5Q0IwRjk3N0M3OUY3ODcxIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkM0RjRBMzAwNTY3NzExRTI5Q0IwRjk3N0M3OUY3ODcxIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+2Di36AAAALBJREFUeNpi+P//PwMQ60NpdMwIxAYgNogTBsQHgNgGi0IVIN4CxH4whSDwAk2xLBCvh8odhgmuRlNsCMSboWLHgDgE2Zp5SIrXQNlXgNgI5kZkh9+AKvgGpZWAmAUkz8SAADxAfAfK5oTS7ED8B8yCmqYOxOuA+AcQXwDiJVATn8I8CFIUCA0CmMNNoZqXILnZHiQQjeRwU7RwhCk+xAB17A4gdgFiNiyBDlKcBBBgAG/qVav+VuC1AAAAAElFTkSuQmCC');\n    }\n    ";
    $minExpected = "div.image{width:100px;height:100px;background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAALCAYAAABGbhwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo1RDg4RDYwQzU2N0ExMUUyOUNCMEY5NzdDNzlGNzg3MSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDo1RDg4RDYwRDU2N0ExMUUyOUNCMEY5NzdDNzlGNzg3MSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkM0RjRBMkZGNTY3NzExRTI5Q0IwRjk3N0M3OUY3ODcxIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkM0RjRBMzAwNTY3NzExRTI5Q0IwRjk3N0M3OUY3ODcxIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+2Di36AAAALBJREFUeNpi+P//PwMQ60NpdMwIxAYgNogTBsQHgNgGi0IVIN4CxH4whSDwAk2xLBCvh8odhgmuRlNsCMSboWLHgDgE2Zp5SIrXQNlXgNgI5kZkh9+AKvgGpZWAmAUkz8SAADxAfAfK5oTS7ED8B8yCmqYOxOuA+AcQXwDiJVATn8I8CFIUCA0CmMNNoZqXILnZHiQQjeRwU7RwhCk+xAB17A4gdgFiNiyBDlKcBBBgAG/qVav+VuC1AAAAAElFTkSuQmCC')}";
    // fails with java.lang.StackOverflowError as of Yui 2.4.6
    // unfortunately error output is not caught from yui, so have to guess
    try {
        $minOutput = Minify_YUICompressor::minifyCss($src);
        echo "      Minify_YUICompressor : Correctly handles input which caused stack overflow in 2.4.6\n";
    } catch (Exception $e) {
        assertTrue($e->getMessage() == 'Minify_YUICompressor : YUI compressor execution failed.', 'Minify_YUICompressor : got expected Exception');
    }
    try {
        $options = array('stack-size' => '2m');
        $minOutput = Minify_YUICompressor::minifyCss($src, $options);
    } catch (Exception $e) {
        assertTrue(false, $e->getMessage());
        $minOutput = false;
    }
    $passed = assertTrue($minExpected == $minOutput, 'Minify_YUICompressor : Overall');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n";
        echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n";
        echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n";
    }
}
开发者ID:chaoyanjie,项目名称:HiBlog,代码行数:33,代码来源:test_Minify_YuiCSS.php

示例6: test_Minify_CSS_UriRewriter

function test_Minify_CSS_UriRewriter()
{
    global $thisDir;
    Minify_CSS_UriRewriter::$debugText = '';
    $in = file_get_contents($thisDir . '/_test_files/css_uriRewriter/in.css');
    $expected = file_get_contents($thisDir . '/_test_files/css_uriRewriter/exp.css');
    $actual = Minify_CSS_UriRewriter::rewrite($in, $thisDir . '/_test_files/css_uriRewriter', $thisDir);
    $passed = assertTrue($expected === $actual, 'Minify_CSS_UriRewriter : rewrite');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Input:\n\n{$in}\n";
        echo "\n---Output: " . countBytes($actual) . " bytes\n\n{$actual}\n\n";
        if (!$passed) {
            echo "---Expected: " . countBytes($expected) . " bytes\n\n{$expected}\n\n\n";
        }
        // show debugging only when test run directly
        echo "--- Minify_CSS_UriRewriter::\$debugText\n\n", Minify_CSS_UriRewriter::$debugText;
    }
    Minify_CSS_UriRewriter::$debugText = '';
    $in = file_get_contents($thisDir . '/_test_files/css_uriRewriter/in.css');
    $expected = file_get_contents($thisDir . '/_test_files/css_uriRewriter/exp_prepend.css');
    $actual = Minify_CSS_UriRewriter::prepend($in, 'http://cnd.com/A/B/');
    $passed = assertTrue($expected === $actual, 'Minify_CSS_UriRewriter : prepend1');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Input:\n\n{$in}\n";
        echo "\n---Output: " . countBytes($actual) . " bytes\n\n{$actual}\n\n";
        if (!$passed) {
            echo "---Expected: " . countBytes($expected) . " bytes\n\n{$expected}\n\n\n";
        }
        // show debugging only when test run directly
        echo "--- Minify_CSS_UriRewriter::\$debugText\n\n", Minify_CSS_UriRewriter::$debugText;
    }
    Minify_CSS_UriRewriter::$debugText = '';
    $in = file_get_contents($thisDir . '/_test_files/css_uriRewriter/in.css');
    $expected = file_get_contents($thisDir . '/_test_files/css_uriRewriter/exp_prepend2.css');
    $actual = Minify_CSS_UriRewriter::prepend($in, '//cnd.com/A/B/');
    $passed = assertTrue($expected === $actual, 'Minify_CSS_UriRewriter : prepend2');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Input:\n\n{$in}\n";
        echo "\n---Output: " . countBytes($actual) . " bytes\n\n{$actual}\n\n";
        if (!$passed) {
            echo "---Expected: " . countBytes($expected) . " bytes\n\n{$expected}\n\n\n";
        }
        // show debugging only when test run directly
        echo "--- Minify_CSS_UriRewriter::\$debugText\n\n", Minify_CSS_UriRewriter::$debugText;
    }
    Minify_CSS_UriRewriter::$debugText = '';
    $in = '../../../../assets/skins/sam/sprite.png';
    $exp = '/yui/assets/skins/sam/sprite.png';
    $actual = Minify_CSS_UriRewriter::rewriteRelative($in, 'sf_root_dir\\web\\yui\\menu\\assets\\skins\\sam', 'sf_root_dir\\web');
    $passed = assertTrue($exp === $actual, 'Minify_CSS_UriRewriter : Issue 99');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Input:\n\n{$in}\n";
        echo "\n---Output: " . countBytes($actual) . " bytes\n\n{$actual}\n\n";
        if (!$passed) {
            echo "---Expected: " . countBytes($exp) . " bytes\n\n{$exp}\n\n\n";
        }
        // show debugging only when test run directly
        echo "--- Minify_CSS_UriRewriter::\$debugText\n\n", Minify_CSS_UriRewriter::$debugText;
    }
}
开发者ID:Bhaavya,项目名称:OpenLorenz,代码行数:60,代码来源:test_Minify_CSS_UriRewriter.php

示例7: test_JSMin

function test_JSMin()
{
    global $thisDir;
    $src = file_get_contents($thisDir . '/_test_files/js/before.js');
    $minExpected = file_get_contents($thisDir . '/_test_files/js/before.min.js');
    $minOutput = JSMin::minify($src);
    assertTrue($minExpected == $minOutput, 'JSMin : Overall');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n";
        echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n";
        echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n";
    }
    $src = file_get_contents($thisDir . '/_test_files/js/issue144.js');
    $minExpected = file_get_contents($thisDir . '/_test_files/js/issue144.min.js');
    $minOutput = JSMin::minify($src);
    assertTrue($minExpected == $minOutput, 'JSMin : Handle "+ ++a" syntax (Issue 144)');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n";
        echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n";
        echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n";
    }
    $src = file_get_contents($thisDir . '/_test_files/js/issue256.js');
    $minExpected = file_get_contents($thisDir . '/_test_files/js/issue256.min.js');
    $minOutput = JSMin::minify($src);
    assertTrue($minExpected == $minOutput, 'JSMin : Handle \\n!function()... (Issue 256)');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n";
        echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n";
        echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n";
    }
    if (function_exists('mb_strlen') && (int) ini_get('mbstring.func_overload') & 2) {
        $src = file_get_contents($thisDir . '/_test_files/js/issue132.js');
        $minExpected = file_get_contents($thisDir . '/_test_files/js/issue132.min.js');
        $minOutput = JSMin::minify($src);
        assertTrue($minExpected == $minOutput, 'JSMin : mbstring.func_overload shouldn\'t cause failure (Issue 132)');
        if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
            echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n";
            echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n";
            echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n";
        }
    }
    $src = file_get_contents($thisDir . '/_test_files/js/regexes.js');
    $minExpected = file_get_contents($thisDir . '/_test_files/js/regexes.min.js');
    $minOutput = JSMin::minify($src);
    assertTrue($minExpected == $minOutput, 'JSMin : Identify RegExp literals');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n";
        echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n";
        echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n";
    }
    test_JSMin_exception('"Hello', 'Unterminated String', 'JSMin_UnterminatedStringException', "JSMin: Unterminated String at byte 5: \"Hello");
    test_JSMin_exception("return /regexp\n}", 'Unterminated RegExp', 'JSMin_UnterminatedRegExpException', "JSMin: Unterminated RegExp at byte 14: /regexp\n");
    test_JSMin_exception("return/regexp\n}", 'Unterminated RegExp', 'JSMin_UnterminatedRegExpException', "JSMin: Unterminated RegExp at byte 13: /regexp\n");
    test_JSMin_exception(";return/regexp\n}", 'Unterminated RegExp', 'JSMin_UnterminatedRegExpException', "JSMin: Unterminated RegExp at byte 14: /regexp\n");
    test_JSMin_exception(";return /regexp\n}", 'Unterminated RegExp', 'JSMin_UnterminatedRegExpException', "JSMin: Unterminated RegExp at byte 15: /regexp\n");
    test_JSMin_exception("typeof/regexp\n}", 'Unterminated RegExp', 'JSMin_UnterminatedRegExpException', "JSMin: Unterminated RegExp at byte 13: /regexp\n");
    test_JSMin_exception("/* Comment ", 'Unterminated Comment', 'JSMin_UnterminatedCommentException', "JSMin: Unterminated comment at byte 11: /* Comment ");
}
开发者ID:speder,项目名称:craft.minimee,代码行数:58,代码来源:test_JSMin.php

示例8: countStrings

function countStrings($in)
{
    $list = explode("\n", $in);
    $tot = 0;
    foreach ($list as $str) {
        if (!$str) {
            continue;
        }
        $code = countCode($str);
        $bytes = countBytes($str);
        $tot -= $code;
        $tot += $bytes;
    }
    echo "Tot is {$tot}\n";
}
开发者ID:JimMackin,项目名称:AdventOfCode,代码行数:15,代码来源:day8-2.php

示例9: test_Minify_CommentPreserver

function test_Minify_CommentPreserver()
{
    global $thisDir;
    $inOut = array('/*!*/' => "\n/*!*/\n", '/*!*/a' => "\n/*!*/\n1A", 'a/*!*//*!*/b' => "2A\n/*!*/\n\n/*!*/\n3B", 'a/*!*/b/*!*/' => "4A\n/*!*/\n5B\n/*!*/\n");
    foreach ($inOut as $in => $expected) {
        $actual = Minify_CommentPreserver::process($in, '_test_MCP_processor');
        $passed = assertTrue($expected === $actual, 'Minify_CommentPreserver');
        if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
            echo "\n---Output: " . countBytes($actual) . " bytes\n\n{$actual}\n\n";
            if (!$passed) {
                echo "---Expected: " . countBytes($expected) . " bytes\n\n{$expected}\n\n\n";
            }
        }
    }
}
开发者ID:Bhaavya,项目名称:OpenLorenz,代码行数:15,代码来源:test_Minify_CommentPreserver.php

示例10: test_Lines

function test_Lines()
{
    global $thisDir;
    $exp = file_get_contents("{$thisDir}/_test_files/minify/lines_output.js");
    Minify::setCache(null);
    // no cache
    $ret = Minify::serve('Files', array('debug' => true, 'quiet' => true, 'encodeOutput' => false, 'files' => array("{$thisDir}/_test_files/minify/email.js", "{$thisDir}/_test_files/minify/lines_bugs.js", "{$thisDir}/_test_files/minify/QueryString.js", "{$thisDir}/_test_files/js/before.js")));
    $passed = assertTrue($exp === $ret['content'], 'Minify_Lines');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Output: " . countBytes($ret['content']) . " bytes\n\n{$ret['content']}\n\n";
        if (!$passed) {
            echo "---Expected: " . countBytes($exp) . " bytes\n\n{$exp}\n\n\n";
        }
    }
}
开发者ID:Bhaavya,项目名称:OpenLorenz,代码行数:15,代码来源:test_Minify_Lines.php

示例11: test_Minify_ImportProcessor

function test_Minify_ImportProcessor()
{
    global $thisDir;
    $linDir = $thisDir . '/_test_files/importProcessor';
    $expected = file_get_contents($linDir . '/css/output.css');
    $actual = Minify_ImportProcessor::process($linDir . '/css/input.css');
    $passed = assertTrue($expected === $actual, 'ImportProcessor');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Output: " . countBytes($actual) . " bytes\n\n{$actual}\n\n";
        if (!$passed) {
            echo "---Expected: " . countBytes($expected) . " bytes\n\n{$expected}\n\n\n";
        }
    }
    $expectedIncludes = array(realpath($linDir . '/css/input.css'), realpath($linDir . '/css/adjacent.css'), realpath($linDir . '/../css/styles.css'), realpath($linDir . '/css/1/tv.css'), realpath($linDir . '/css/1/adjacent.css'), realpath($linDir . '/lib/css/example.css'));
    $passed = assertTrue($expectedIncludes === Minify_ImportProcessor::$filesIncluded, 'ImportProcessor : included right files in right order');
}
开发者ID:chaoyanjie,项目名称:HiBlog,代码行数:16,代码来源:test_Minify_ImportProcessor.php

示例12: test_Minify_ClosureCompiler

function test_Minify_ClosureCompiler()
{
    global $thisDir;
    Minify_ClosureCompiler::$isDebug = true;
    // --- Test minification w/o setting the necessary settings ---
    try {
        Minify_ClosureCompiler::minify('');
    } catch (Exception $e) {
        $exc = $e;
    }
    $passed = assertTrue($exc instanceof Minify_ClosureCompiler_Exception, 'Minify_ClosureCompiler : Throws Minify_ClosureCompiler_Exception');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Message: " . var_export($exc->getMessage(), 1) . "\n\n\n";
    }
    $compiler_jar_path = __DIR__ . DIRECTORY_SEPARATOR . 'compiler.jar';
    if (is_file($compiler_jar_path)) {
        // set minimum necessary settings
        Minify_ClosureCompiler::$jarFile = $compiler_jar_path;
        Minify_ClosureCompiler::$tempDir = sys_get_temp_dir();
        // --- Test minification with the minimum necessary settings ---
        $src = "\n    (function (window, undefined){\n        function addOne(input) {\n            return 1 + input;\n        }\n        window.addOne = addOne;\n        window.undefined = undefined;\n    })(window);\n        ";
        $minExpected = "(function(a,b){a.addOne=function(a){return 1+a};a.undefined=b})(window);";
        $minOutput = Minify_ClosureCompiler::minify($src);
        $passed = assertTrue($minExpected == $minOutput, 'Minify_ClosureCompiler : minimum necessary settings');
        if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
            echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n";
            echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n";
            echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n";
        }
        // --- Test minification with advanced compilation level ---
        $src = "function unused() {};";
        $minExpected = '';
        $minOutput = Minify_ClosureCompiler::minify($src, array(Minify_ClosureCompiler::OPTION_COMPILATION_LEVEL => 'ADVANCED_OPTIMIZATIONS'));
        $passed = assertTrue($minExpected == $minOutput, 'Minify_ClosureCompiler : advanced optimizations');
        if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
            echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n";
            echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n";
            echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n";
        }
    } else {
        echo "      Minify_ClosureCompiler : To test more functionality, download a compiler.jar from\n";
        echo "                               https://code.google.com/p/closure-compiler/wiki/BinaryDownloads,\n";
        echo "                               put it under '{$compiler_jar_path}',\n";
        echo "                               and make it readable by your webserver\n";
    }
}
开发者ID:chaoyanjie,项目名称:HiBlog,代码行数:46,代码来源:test_Minify_ClosureCompiler.php

示例13: test_Lines

function test_Lines()
{
    global $thisDir;
    $exp = file_get_contents("{$thisDir}/_test_files/minify/lines_output.js");
    $env = new Minify_Env();
    $sourceFactory = new Minify_Source_Factory($env, array(), new Minify_Cache_Null());
    $controller = new Minify_Controller_Files($env, $sourceFactory);
    $minify = new Minify(new Minify_Cache_Null());
    $ret = $minify->serve($controller, array('debug' => true, 'quiet' => true, 'encodeOutput' => false, 'files' => array("{$thisDir}/_test_files/js/before.js")));
    $passed = assertTrue($exp === $ret['content'], 'Minify_Lines');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Output: " . countBytes($ret['content']) . " bytes\n\n{$ret['content']}\n\n";
        if (!$passed) {
            echo "---Expected: " . countBytes($exp) . " bytes\n\n{$exp}\n\n\n";
        }
    }
}
开发者ID:chaoyanjie,项目名称:HiBlog,代码行数:17,代码来源:test_Minify_Lines.php

示例14: test_Minify_ImportProcessor

function test_Minify_ImportProcessor()
{
    global $thisDir;
    $linDir = $thisDir . '/_test_files/importProcessor';
    $testFilesUri = substr(realpath($thisDir . '/_test_files'), strlen(realpath($_SERVER['DOCUMENT_ROOT'])));
    $testFilesUri = str_replace('\\', '/', $testFilesUri);
    $expected = str_replace('%TEST_FILES_URI%', $testFilesUri, file_get_contents($linDir . '/output.css'));
    $actual = Minify_ImportProcessor::process($linDir . '/input.css');
    $passed = assertTrue($expected === $actual, 'ImportProcessor');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Output: " . countBytes($actual) . " bytes\n\n{$actual}\n\n";
        if (!$passed) {
            echo "---Expected: " . countBytes($expected) . " bytes\n\n{$expected}\n\n\n";
        }
    }
    $expectedIncludes = array(realpath($linDir . '/input.css'), realpath($linDir . '/adjacent.css'), realpath($linDir . '/../css/styles.css'), realpath($linDir . '/1/tv.css'), realpath($linDir . '/1/adjacent.css'));
    $passed = assertTrue($expectedIncludes === Minify_ImportProcessor::$filesIncluded, 'ImportProcessor : included right files in right order');
}
开发者ID:Ralle,项目名称:minify,代码行数:18,代码来源:test_Minify_ImportProcessor.php

示例15: test

/**
 * Prints a test result
 */
function test($file, $minExpected, $skip)
{
    global $cssmin;
    if (!empty($skip) && in_array(basename($file), $skip)) {
        p("INFO: CSSmin: skipping " . basename($file), 'info');
        return;
    }
    $src = file_get_contents($file);
    $minOutput = $cssmin->run($src);
    $passed = assertTrue(strcmp($minOutput, $minExpected) === 0, 'CSSmin: ' . basename(dirname($file)) . '/' . basename($file));
    if (!$passed) {
        p("---Output: " . countBytes($minOutput) . " bytes", '');
        $opcodes = FineDiff::getDiffOpcodes($minExpected, $minOutput);
        code(FineDiff::renderDiffToHTMLFromOpcodes($minExpected, $opcodes));
        p("---Expected: " . countBytes($minExpected) . " bytes", '');
        code($minExpected);
        p("---Source: " . countBytes($src) . " bytes", '');
        code($src);
    }
}
开发者ID:Flesh192,项目名称:magento,代码行数:23,代码来源:run.php


注:本文中的countBytes函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。