⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 yuitest-debug.js

📁 这是YUI的源码及相关示例。里面有很多很炫的Javascript效果。
💻 JS
📖 第 1 页 / 共 5 页
字号:
            if (failed) {                this.fireEvent(this.TEST_FAIL_EVENT, { testCase: testCase, testName: testName, error: error });            } else {                this.fireEvent(this.TEST_PASS_EVENT, { testCase: testCase, testName: testName });            }                        //run the tear down            testCase.tearDown();                        //update results            node.parent.results[testName] = {                 result: failed ? "fail" : "pass",                message: error ? error.getMessage() : "Test passed",                type: "test",                name: testName            };                        if (failed){                node.parent.results.failed++;            } else {                node.parent.results.passed++;            }            node.parent.results.total++;            //set timeout not supported in all environments            if (typeof setTimeout != "undefined"){                setTimeout(function(){                    YAHOO.tool.TestRunner._run();                }, 0);            } else {                this._run();            }                },                        /**         * Runs a single test based on the data provided in the node.         * @param {TestNode} node The TestNode representing the test to run.         * @return {Void}         * @static         * @private         * @name _runTest         */        _runTest : function (node /*:TestNode*/) /*:Void*/ {                    //get relevant information            var testName /*:String*/ = node.testObject;            var testCase /*:YAHOO.tool.TestCase*/ = node.parent.testObject;            var test /*:Function*/ = testCase[testName];                        //get the "should" test cases            var shouldIgnore /*:Object*/ = (testCase._should.ignore || {})[testName];                        //figure out if the test should be ignored or not            if (shouldIgnore){                            //update results                node.parent.results[testName] = {                     result: "ignore",                    message: "Test ignored",                    type: "test",                    name: testName                };                                node.parent.results.ignored++;                node.parent.results.total++;                            this.fireEvent(this.TEST_IGNORE_EVENT, { testCase: testCase, testName: testName });                                //some environments don't support setTimeout                if (typeof setTimeout != "undefined"){                                        setTimeout(function(){                        YAHOO.tool.TestRunner._run();                    }, 0);                              } else {                    this._run();                }            } else {                            //run the setup                testCase.setUp();                                //now call the body of the test                this._resumeTest(test);                            }        },                        //-------------------------------------------------------------------------        // Protected Methods        //-------------------------------------------------------------------------               /**         * Fires events for the TestRunner. This overrides the default fireEvent()         * method from EventProvider to add the type property to the data that is         * passed through on each event call.         * @param {String} type The type of event to fire.         * @param {Object} data (Optional) Data for the event.         * @method fireEvent         * @static         * @protected         */        fireEvent : function (type /*:String*/, data /*:Object*/) /*:Void*/ {            data = data || {};            data.type = type;            TestRunner.superclass.fireEvent.call(this, type, data);        },                //-------------------------------------------------------------------------        // Public Methods        //-------------------------------------------------------------------------               /**         * Adds a test suite or test case to the list of test objects to run.         * @param testObject Either a TestCase or a TestSuite that should be run.         * @return {Void}         * @method add         * @static         */        add : function (testObject /*:Object*/) /*:Void*/ {            this.masterSuite.add(testObject);        },                /**         * Removes all test objects from the runner.         * @return {Void}         * @method clear         * @static         */        clear : function () /*:Void*/ {            this.masterSuite.items = [];        },                /**         * Resumes the TestRunner after wait() was called.         * @param {Function} segment The function to run as the rest         *      of the haulted test.         * @return {Void}         * @method resume         * @static         */        resume : function (segment /*:Function*/) /*:Void*/ {            this._resumeTest(segment || function(){});        },            /**         * Runs the test suite.         * @return {Void}         * @method run         * @static         */        run : function (testObject /*:Object*/) /*:Void*/ {                        //pointer to runner to avoid scope issues             var runner = YAHOO.tool.TestRunner;            //build the test tree            runner._buildTestTree();                        //set when the test started            runner._root.results.duration = (new Date()).valueOf();                        //fire the begin event            runner.fireEvent(runner.BEGIN_EVENT);                   //begin the testing            runner._run();        }        });        return new TestRunner();    })();YAHOO.namespace("util");//-----------------------------------------------------------------------------// Assert object//-----------------------------------------------------------------------------/** * The Assert object provides functions to test JavaScript values against * known and expected results. Whenever a comparison (assertion) fails, * an error is thrown. * * @namespace YAHOO.util * @class Assert * @static */YAHOO.util.Assert = {    //-------------------------------------------------------------------------    // Helper Methods    //-------------------------------------------------------------------------        /**     * Formats a message so that it can contain the original assertion message     * in addition to the custom message.     * @param {String} customMessage The message passed in by the developer.     * @param {String} defaultMessage The message created by the error by default.     * @return {String} The final error message, containing either or both.     * @protected     * @static     * @method _formatMessage     */    _formatMessage : function (customMessage /*:String*/, defaultMessage /*:String*/) /*:String*/ {        var message = customMessage;        if (YAHOO.lang.isString(customMessage) && customMessage.length > 0){            return YAHOO.lang.substitute(customMessage, { message: defaultMessage });        } else {            return defaultMessage;        }            },        //-------------------------------------------------------------------------    // Generic Assertion Methods    //-------------------------------------------------------------------------        /**      * Forces an assertion error to occur.     * @param {String} message (Optional) The message to display with the failure.     * @method fail     * @static     */    fail : function (message /*:String*/) /*:Void*/ {        throw new YAHOO.util.AssertionError(this._formatMessage(message, "Test force-failed."));    },               //-------------------------------------------------------------------------    // Equality Assertion Methods    //-------------------------------------------------------------------------            /**     * Asserts that a value is equal to another. This uses the double equals sign     * so type cohersion may occur.     * @param {Object} expected The expected value.     * @param {Object} actual The actual value to test.     * @param {String} message (Optional) The message to display if the assertion fails.     * @method areEqual     * @static     */    areEqual : function (expected /*:Object*/, actual /*:Object*/, message /*:String*/) /*:Void*/ {        if (expected != actual) {            throw new YAHOO.util.ComparisonFailure(this._formatMessage(message, "Values should be equal."), expected, actual);        }    },        /**     * Asserts that a value is not equal to another. This uses the double equals sign     * so type cohersion may occur.     * @param {Object} unexpected The unexpected value.     * @param {Object} actual The actual value to test.     * @param {String} message (Optional) The message to display if the assertion fails.     * @method areNotEqual     * @static     */    areNotEqual : function (unexpected /*:Object*/, actual /*:Object*/,                          message /*:String*/) /*:Void*/ {        if (unexpected == actual) {            throw new YAHOO.util.UnexpectedValue(this._formatMessage(message, "Values should not be equal."), unexpected);        }    },        /**     * Asserts that a value is not the same as another. This uses the triple equals sign     * so no type cohersion may occur.     * @param {Object} unexpected The unexpected value.     * @param {Object} actual The actual value to test.     * @param {String} message (Optional) The message to display if the assertion fails.     * @method areNotSame     * @static     */    areNotSame : function (unexpected /*:Object*/, actual /*:Object*/, message /*:String*/) /*:Void*/ {        if (unexpected === actual) {            throw new YAHOO.util.UnexpectedValue(this._formatMessage(message, "Values should not be the same."), unexpected);        }    },    /**     * Asserts that a value is the same as another. This uses the triple equals sign     * so no type cohersion may occur.     * @param {Object} expected The expected value.     * @param {Object} actual The actual value to test.     * @param {String} message (Optional) The message to display if the assertion fails.     * @method areSame     * @static     */    areSame : function (expected /*:Object*/, actual /*:Object*/, message /*:String*/) /*:Void*/ {        if (expected !== actual) {            throw new YAHOO.util.ComparisonFailure(this._formatMessage(message, "Values should be the same."), expected, actual);        }    },            //-------------------------------------------------------------------------    // Boolean Assertion Methods    //-------------------------------------------------------------------------            /**     * Asserts that a value is false. This uses the triple equals sign     * so no type cohersion may occur.     * @param {Object} actual The actual value to test.     * @param {String} message (Optional) The message to display if the assertion fails.     * @method isFalse     * @static     */    isFalse : function (actual /*:Boolean*/, message /*:String*/) {        if (false !== actual) {            throw new YAHOO.util.ComparisonFailure(this._formatMessage(message, "Value should be false."), false, actual);        }    },        /**     * Asserts that a value is true. This uses the triple equals sign     * so no type cohersion may occur.     * @param {Object} actual The actual value to test.     * @param {String} message (Optional) The message to display if the assertion fails.     * @method isTrue     * @static     */    isTrue : function (actual /*:Boolean*/, message /*:String*/) /*:Void*/ {        if (true !== actual) {            throw new YAHOO.util.ComparisonFailure(this._formatMessage(message, "Value should be true."), true, actual);        }    },        //-------------------------------------------------------------------------    // Special Value Assertion Methods    //-------------------------------------------------------------------------            /**     * Asserts that a value is not a number.     * @param {Object} actual The value to test.     * @param {String} message (Optional) The message to display if the assertion fails.     * @method isNaN     * @static     */    isNaN : function (actual /*:Object*/, message /*:String*/) /*:Void*/{        if (!isNaN(actual)){            throw new YAHOO.util.ComparisonFailure(this._formatMessage(message, "Value should be NaN."), NaN, actual);        }        },        /**     * Asserts that a value is not the special NaN value.     * @param {Object} actual The value to test.     * @param {String} message (Optional) The message to display if the assertion fails.     * @method isNotNaN     * @static     */    isNotNaN : function (actual /*:Object*/, message /*:String*/) /*:Void*/{        if (isNaN(actual)){            throw new YAHOO.util.UnexpectedValue(this._formatMessage(message, "Values should not be NaN."), NaN);        }        },        /**     * Asserts that a value is not null. This uses the triple equals sign     * so no type cohersion may occur.     * @param {Object} actual The actual value to test.     * @param {String} message (Optional) The message to display if the assertion fails.     * @method isNotNull

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -