test-debug.js revision af3ee734c3099cd0ac6ece4fbf2c15c173a6c55e
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * YUI JavaScript Testing Framework
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @module yuitest
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Test case containing various tests to run.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param template An object containing any number of test methods, other methods,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * an optional name, and anything else the test case needs.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @class Case
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @namespace Test
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @constructor
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Special rules for the test case. Possible subobjects
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * are fail, for tests that should fail, and error, for
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * tests that should throw an error.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //copy over all properties from the template to this object
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //check for a valid name
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Name for the test case.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Resumes a paused test and runs the given function.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Function} segment (Optional) The function to run.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * If omitted, the test automatically passes.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @return {Void}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method resume
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync resume : function (segment /*:Function*/) /*:Void*/ {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Causes the test case to wait a specified amount of time and then
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * continue executing the given code.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Function} segment (Optional) The function to run after the delay.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * If omitted, the TestRunner will wait until resume() is called.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {int} delay (Optional) The number of milliseconds to wait before running
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * the function. If omitted, defaults to zero.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @return {Void}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method wait
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync wait : function (segment /*:Function*/, delay /*:int*/) /*:Void*/{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync Y.Assert.fail("Timeout: wait() called but resume() never called.");
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync // Stub Methods
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-------------------------------------------------------------------------
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync * Function to run before each test is executed.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @return {Void}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method setUp
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Function to run after each test is executed.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @return {Void}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method tearDown
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Represents a stoppage in test execution to wait for an amount of time before
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * continuing.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Function} segment A function to run when the wait is over.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {int} delay The number of milliseconds to wait before running the code.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @class Wait
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @namespace Test
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @constructor
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync Y.Test.Wait = function (segment /*:Function*/, delay /*:int*/) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * The segment of code to run when the wait is over.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @type Function
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @property segment
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this.segment /*:Function*/ = (Y.Lang.isFunction(segment) ? segment : null);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * The delay before running the segment of code.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @type int
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @property delay
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this.delay /*:int*/ = (Y.Lang.isNumber(delay) ? delay : 0);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * A test suite that can contain a collection of TestCase and TestSuite objects.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {String||Object} data The name of the test suite or an object containing
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * a name property as well as setUp and tearDown methods.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @namespace Test
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @class Suite
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @constructor
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync Y.Test.Suite = function (data /*:String||Object*/) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * The name of the test suite.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @type String
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @property name
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Array of test suites and
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //initialize the properties
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //double-check name
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Adds a test suite or test case to the test suite.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Y.Test.Suite||Y.Test.Case} testObject The test suite or test case to add.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @return {Void}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method add
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync add : function (testObject /*:Y.Test.Suite*/) /*:Void*/ {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (testObject instanceof Y.Test.Suite || testObject instanceof Y.Test.Case) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync // Stub Methods
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Function to run before each test is executed.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @return {Void}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method setUp
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Function to run after each test is executed.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @return {Void}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method tearDown
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Runs test suites and test cases, providing events to allowing for the
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * interpretation of test results.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @namespace Test
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @class Runner
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * A node in the test tree structure. May represent a TestSuite, TestCase, or
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * test function.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Variant} testObject A TestSuite, TestCase, or the name of a test function.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @class TestNode
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @constructor
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * The TestSuite, TestCase, or test function represented by this node.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @type Variant
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @property testObject
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Pointer to this node's first child.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @type TestNode
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @property firstChild
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Pointer to this node's last child.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @type TestNode
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @property lastChild
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Pointer to this node's parent.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @type TestNode
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @property parent
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this.parent = null;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Pointer to this node's next sibling.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @type TestNode
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @property next
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this.next = null;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Test results for this test object.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @type object
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @property results
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //initialize results
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Appends a new test object (TestSuite, TestCase, or test function name) as a child
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * of this node.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Variant} testObject A TestSuite, TestCase, or the name of a test function.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @return {Void}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync appendChild : function (testObject /*:Variant*/) /*:Void*/{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (this.firstChild === null){
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Runs test suites and test cases, providing events to allowing for the
11c2b573e2625474a51ae55ee1f3f82936f125davboxsync * interpretation of test results.
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync * @namespace Test
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @class Runner
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //inherit from EventProvider
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TestRunner.superclass.constructor.apply(this,arguments);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Suite on which to attach all TestSuites and TestCases to be run.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @type Y.Test.Suite
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @property masterSuite
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this.masterSuite /*:Y.Test.Suite*/ = new Y.Test.Suite("YUI Test Results");
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Pointer to the current node in the test tree.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @type TestNode
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @property _cur
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this._cur = null;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Pointer to the root node in the test tree.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @type TestNode
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @property _root
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this._root = null;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Indicates if the TestRunner will log events or not.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @type Boolean
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @property _log
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this._log = true;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //create events
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this.subscribe(events[i], this._logEvent, this, true);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync // Constants
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Fires when a test case is opened but before the first
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * test is executed.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @event testcasebegin
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TEST_CASE_BEGIN_EVENT /*:String*/ : "testcasebegin",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Fires when all tests in a test case have been executed.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @event testcasecomplete
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TEST_CASE_COMPLETE_EVENT /*:String*/ : "testcasecomplete",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Fires when a test suite is opened but before the first
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * test is executed.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @event testsuitebegin
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TEST_SUITE_BEGIN_EVENT /*:String*/ : "testsuitebegin",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Fires when all test cases in a test suite have been
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * completed.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @event testsuitecomplete
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync TEST_SUITE_COMPLETE_EVENT /*:String*/ : "testsuitecomplete",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Fires when a test has passed.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @event pass
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Fires when a test has failed.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @event fail
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Fires when a test has been ignored.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @event ignore
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Fires when all test suites and test cases have been completed.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @event complete
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Fires when the run() method is called.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @event begin
090c459b9e90ca46e2ce2b8c81533ade3b23f3e9vboxsync //-------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync // Logging-Related Methods
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Disable logging via Y.log(). Test output will not be visible unless
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * TestRunner events are subscribed to.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @return {Void}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method disableLogging
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this._log = false;
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync * Enable logging via Y.log(). Test output is published and can be read via
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync * logreader.
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync * @return {Void}
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync * @method enableLogging
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync this._log = true;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Logs TestRunner events using Y.log().
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync * @param {Object} event The event object for the event.
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync * @return {Void}
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync * @method _logEvent
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync //data variables
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync message = "Testing began at " + (new Date()).toString() + ".";
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync message = "Testing completed at " + (new Date()).toString() + ".\nPassed:" +
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync event.results.passed + " Failed:" + event.results.failed + " Total:" + event.results.total;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync message = event.testName + ": " + event.error.getMessage();
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync message = "Test suite \"" + event.testSuite.name + "\" started.";
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync message = "Test suite \"" + event.testSuite.name + "\" completed.\nPassed:" +
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync event.results.passed + " Failed:" + event.results.failed + " Total:" + event.results.total;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync message = "Test case \"" + event.testCase.name + "\" started.";
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync message = "Test case \"" + event.testCase.name + "\" completed.\nPassed:" +
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync event.results.passed + " Failed:" + event.results.failed + " Total:" + event.results.total;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //only log if required
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync // Test Tree-Related Methods
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Adds a test case to the test tree as a child of the specified node.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {TestNode} parentNode The node to add the test case to as a child.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Y.Test.Case} testCase The test case to add.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @return {Void}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method _addTestCaseToTestTree
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync _addTestCaseToTestTree : function (parentNode /*:TestNode*/, testCase /*:Y.Test.Case*/) /*:Void*/{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //add the test suite
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //iterate over the items in the test case
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (prop.indexOf("test") === 0 && Y.Lang.isFunction(testCase[prop])){
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Adds a test suite to the test tree as a child of the specified node.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {TestNode} parentNode The node to add the test suite to as a child.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Y.Test.Suite} testSuite The test suite to add.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @return {Void}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method _addTestSuiteToTestTree
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync _addTestSuiteToTestTree : function (parentNode /*:TestNode*/, testSuite /*:Y.Test.Suite*/) /*:Void*/ {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //add the test suite
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //iterate over the items in the master suite
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this._addTestSuiteToTestTree(node, testSuite.items[i]);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync } else if (testSuite.items[i] instanceof Y.Test.Case) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this._addTestCaseToTestTree(node, testSuite.items[i]);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Builds the test tree based on items in the master suite. The tree is a hierarchical
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * representation of the test suites, test cases, and test functions. The resulting tree
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * is stored in _root and the pointer _cur is set to the root initially.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @return {Void}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method _buildTestTree
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //iterate over the items in the master suite
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync for (var i=0; i < this.masterSuite.items.length; i++){
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (this.masterSuite.items[i] instanceof Y.Test.Suite) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this._addTestSuiteToTestTree(this._root, this.masterSuite.items[i]);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync } else if (this.masterSuite.items[i] instanceof Y.Test.Case) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this._addTestCaseToTestTree(this._root, this.masterSuite.items[i]);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync // Private Methods
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Handles the completion of a test object's tests. Tallies test results
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * from one level up to the next.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {TestNode} node The TestNode representing the test object.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @return {Void}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method _handleTestObjectComplete
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync _handleTestObjectComplete : function (node /*:TestNode*/) /*:Void*/ {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync node.parent.results.ignored += node.results.ignored;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync node.parent.results[node.testObject.name] = node.results;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this.fire(this.TEST_SUITE_COMPLETE_EVENT, { testSuite: node.testObject, results: node.results});
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync } else if (node.testObject instanceof Y.Test.Case){
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this.fire(this.TEST_CASE_COMPLETE_EVENT, { testCase: node.testObject, results: node.results});
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync // Navigation Methods
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Retrieves the next node in the test tree.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @return {TestNode} The next node in the test tree or null if the end is reached.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method _next
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync while (this._cur && !this._cur.next && this._cur !== this._root){
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this._cur.results.timestamp = (new Date()).toLocaleString();
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this._cur.results.duration = (new Date()) - this._cur.results.duration;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this.fire(this.COMPLETE_EVENT, { results: this._cur.results});
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this._cur = null;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return this._cur;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Runs a test case or test suite, returning the results.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Y.Test.Case|Y.Test.Suite} testObject The test case or test suite to run.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @return {Object} Results of the execution with properties passed, failed, and total.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method _run
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //flag to indicate if the TestRunner should wait before continuing
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //get the next test node
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (node !== null) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //figure out what to do
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this.fire(this.TEST_SUITE_BEGIN_EVENT, { testSuite: testObject });
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this.fire(this.TEST_CASE_BEGIN_EVENT, { testCase: testObject });
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync //some environments don't support setTimeout
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync _resumeTest : function (segment /*:Function*/) /*:Void*/ {
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync //get relevant information
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync //if there's no node, it probably means a wait() was called after resume()
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //TODO: Handle in some way?
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //console.log("wait() called after resume()");
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //this.fire("error", { testCase: "(unknown)", test: "(unknown)", error: new Error("wait() called after resume()")} );
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync var testCase /*:Y.Test.Case*/ = node.parent.testObject;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //cancel other waits if available
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //get the "should" test cases
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync var shouldFail /*:Object*/ = (testCase._should.fail || {})[testName];
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync var shouldError /*:Object*/ = (testCase._should.error || {})[testName];
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //variable to hold whether or not the test failed
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //try the test
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //run the test
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //if it should fail, and it got here, then it's a fail because it didn't
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //cancel any pending waits, the test already failed
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //figure out what type of error it was
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //some environments don't support setTimeout
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync throw new Error("Asynchronous tests not supported in this environment.");
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //first check to see if it should error
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //check to see what type of data we have
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //if it's a string, check the error message
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //if it's a function, see if the error is an instance of it
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //if it's an object, check the instance and message
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (!(thrown instanceof shouldError.constructor) ||
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //fire appropriate event
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this.fire(this.TEST_FAIL_EVENT, { testCase: testCase, testName: testName, error: error });
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this.fire(this.TEST_PASS_EVENT, { testCase: testCase, testName: testName });
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //run the tear down
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //update results
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync message: error ? error.getMessage() : "Test passed",
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //set timeout not supported in all environments
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Runs a single test based on the data provided in the node.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {TestNode} node The TestNode representing the test to run.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @return {Void}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @name _runTest
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync _runTest : function (node /*:TestNode*/) /*:Void*/ {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //get relevant information
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync var testCase /*:Y.Test.Case*/ = node.parent.testObject;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //get the "should" test cases
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync var shouldIgnore /*:Object*/ = (testCase._should.ignore || {})[testName];
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync //figure out if the test should be ignored or not
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync //update results
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync this.fire(this.TEST_IGNORE_EVENT, { testCase: testCase, testName: testName });
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //some environments don't support setTimeout
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //run the setup
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //now call the body of the test
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync // Protected Methods
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Fires events for the TestRunner. This overrides the default fire()
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * method from EventProvider to add the type property to the data that is
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * passed through on each event call.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {String} type The type of event to fire.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} data (Optional) Data for the event.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method fire
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @protected
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync fire : function (type /*:String*/, data /*:Object*/) /*:Void*/ {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync // Public Methods
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Adds a test suite or test case to the list of test objects to run.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param testObject Either a TestCase or a TestSuite that should be run.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @return {Void}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method add
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync add : function (testObject /*:Object*/) /*:Void*/ {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Removes all test objects from the runner.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @return {Void}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method clear
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Resumes the TestRunner after wait() was called.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Function} segment The function to run as the rest
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * of the haulted test.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @return {Void}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method resume
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync resume : function (segment /*:Function*/) /*:Void*/ {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Runs the test suite.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @return {Void}
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method run
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync run : function (testObject /*:Object*/) /*:Void*/ {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //pointer to runner to avoid scope issues
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //build the test tree
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //set when the test started
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync runner._root.results.duration = (new Date()).valueOf();
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //fire the begin event
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //begin the testing
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return new TestRunner();
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * The Assert object provides functions to test JavaScript values against
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * known and expected results. Whenever a comparison (assertion) fails,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * an error is thrown.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @class Assert
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * The number of assertions performed.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @property _asserts
090c459b9e90ca46e2ce2b8c81533ade3b23f3e9vboxsync * @type int
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-------------------------------------------------------------------------
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync // Helper Methods
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync //-------------------------------------------------------------------------
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync * Formats a message so that it can contain the original assertion message
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync * in addition to the custom message.
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync * @param {String} customMessage The message passed in by the developer.
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync * @param {String} defaultMessage The message created by the error by default.
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync * @return {String} The final error message, containing either or both.
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync * @protected
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync * @method _formatMessage
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync _formatMessage : function (customMessage /*:String*/, defaultMessage /*:String*/) /*:String*/ {
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync if (Y.Lang.isString(customMessage) && customMessage.length > 0){
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync return Y.Lang.substitute(customMessage, { message: defaultMessage });
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync * Returns the number of assertions that have been performed.
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync * @method _getCount
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync * @protected
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync return this._asserts;
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync * Increments the number of assertions that have been performed.
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync * @method _increment
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync * @protected
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Resets the number of assertions that have been performed to 0.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method _reset
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @protected
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync _reset: function(){
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync //-------------------------------------------------------------------------
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync // Generic Assertion Methods
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync //-------------------------------------------------------------------------
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync * Forces an assertion error to occur.
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync * @param {String} message (Optional) The message to display with the failure.
be9960565d2df0031f0e6c8a4610f5f0ae8c1845vboxsync * @method fail
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync throw new Y.Assert.Error(Y.Assert._formatMessage(message, "Test force-failed."));
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync // Equality Assertion Methods
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Asserts that a value is equal to another. This uses the double equals sign
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * so type cohersion may occur.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} expected The expected value.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} actual The actual value to test.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {String} message (Optional) The message to display if the assertion fails.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method areEqual
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync areEqual : function (expected /*:Object*/, actual /*:Object*/, message /*:String*/) /*:Void*/ {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync throw new Y.Assert.ComparisonFailure(Y.Assert._formatMessage(message, "Values should be equal."), expected, actual);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Asserts that a value is not equal to another. This uses the double equals sign
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * so type cohersion may occur.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} unexpected The unexpected value.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} actual The actual value to test.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {String} message (Optional) The message to display if the assertion fails.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method areNotEqual
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync areNotEqual : function (unexpected /*:Object*/, actual /*:Object*/,
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync throw new Y.Assert.UnexpectedValue(Y.Assert._formatMessage(message, "Values should not be equal."), unexpected);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Asserts that a value is not the same as another. This uses the triple equals sign
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * so no type cohersion may occur.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} unexpected The unexpected value.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} actual The actual value to test.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {String} message (Optional) The message to display if the assertion fails.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method areNotSame
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync areNotSame : function (unexpected /*:Object*/, actual /*:Object*/, message /*:String*/) /*:Void*/ {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync throw new Y.Assert.UnexpectedValue(Y.Assert._formatMessage(message, "Values should not be the same."), unexpected);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Asserts that a value is the same as another. This uses the triple equals sign
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * so no type cohersion may occur.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} expected The expected value.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} actual The actual value to test.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {String} message (Optional) The message to display if the assertion fails.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method areSame
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync areSame : function (expected /*:Object*/, actual /*:Object*/, message /*:String*/) /*:Void*/ {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync throw new Y.Assert.ComparisonFailure(Y.Assert._formatMessage(message, "Values should be the same."), expected, actual);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync // Boolean Assertion Methods
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Asserts that a value is false. This uses the triple equals sign
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * so no type cohersion may occur.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} actual The actual value to test.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {String} message (Optional) The message to display if the assertion fails.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method isFalse
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync isFalse : function (actual /*:Boolean*/, message /*:String*/) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (false !== actual) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync throw new Y.Assert.ComparisonFailure(Y.Assert._formatMessage(message, "Value should be false."), false, actual);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Asserts that a value is true. This uses the triple equals sign
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * so no type cohersion may occur.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} actual The actual value to test.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {String} message (Optional) The message to display if the assertion fails.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method isTrue
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync isTrue : function (actual /*:Boolean*/, message /*:String*/) /*:Void*/ {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync if (true !== actual) {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync throw new Y.Assert.ComparisonFailure(Y.Assert._formatMessage(message, "Value should be true."), true, actual);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync // Special Value Assertion Methods
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Asserts that a value is not a number.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} actual The value to test.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {String} message (Optional) The message to display if the assertion fails.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method isNaN
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync isNaN : function (actual /*:Object*/, message /*:String*/) /*:Void*/{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync throw new Y.Assert.ComparisonFailure(Y.Assert._formatMessage(message, "Value should be NaN."), NaN, actual);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Asserts that a value is not the special NaN value.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} actual The value to test.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {String} message (Optional) The message to display if the assertion fails.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method isNotNaN
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync isNotNaN : function (actual /*:Object*/, message /*:String*/) /*:Void*/{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync throw new Y.Assert.UnexpectedValue(Y.Assert._formatMessage(message, "Values should not be NaN."), NaN);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Asserts that a value is not null. This uses the triple equals sign
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * so no type cohersion may occur.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} actual The actual value to test.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {String} message (Optional) The message to display if the assertion fails.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method isNotNull
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync isNotNull : function (actual /*:Object*/, message /*:String*/) /*:Void*/ {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync throw new Y.Assert.UnexpectedValue(Y.Assert._formatMessage(message, "Values should not be null."), null);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Asserts that a value is not undefined. This uses the triple equals sign
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * so no type cohersion may occur.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} actual The actual value to test.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {String} message (Optional) The message to display if the assertion fails.
b2e90826ea719b22452d1ff7b977d4f40995b428vboxsync * @method isNotUndefined
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync isNotUndefined : function (actual /*:Object*/, message /*:String*/) /*:Void*/ {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync throw new Y.Assert.UnexpectedValue(Y.Assert._formatMessage(message, "Value should not be undefined."), undefined);
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync * Asserts that a value is null. This uses the triple equals sign
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync * so no type cohersion may occur.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} actual The actual value to test.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {String} message (Optional) The message to display if the assertion fails.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method isNull
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync isNull : function (actual /*:Object*/, message /*:String*/) /*:Void*/ {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync throw new Y.Assert.ComparisonFailure(Y.Assert._formatMessage(message, "Value should be null."), null, actual);
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync * Asserts that a value is undefined. This uses the triple equals sign
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync * so no type cohersion may occur.
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync * @param {Object} actual The actual value to test.
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync * @param {String} message (Optional) The message to display if the assertion fails.
a144bb4a097a1818739e00ba31bea88ce63f5345vboxsync * @method isUndefined
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync isUndefined : function (actual /*:Object*/, message /*:String*/) /*:Void*/ {
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync throw new Y.Assert.ComparisonFailure(Y.Assert._formatMessage(message, "Value should be undefined."), undefined, actual);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //--------------------------------------------------------------------------
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync // Instance Assertion Methods
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //--------------------------------------------------------------------------
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync * Asserts that a value is an array.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} actual The value to test.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {String} message (Optional) The message to display if the assertion fails.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method isArray
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync isArray : function (actual /*:Object*/, message /*:String*/) /*:Void*/ {
daf1b2aee694fc8aca9e056e825b3359170ecf37vboxsync throw new Y.Assert.UnexpectedValue(Y.Assert._formatMessage(message, "Value should be an array."), actual);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Asserts that a value is a Boolean.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} actual The value to test.
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync * @param {String} message (Optional) The message to display if the assertion fails.
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync * @method isBoolean
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync isBoolean : function (actual /*:Object*/, message /*:String*/) /*:Void*/ {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync throw new Y.Assert.UnexpectedValue(Y.Assert._formatMessage(message, "Value should be a Boolean."), actual);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Asserts that a value is a function.
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync * @param {Object} actual The value to test.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {String} message (Optional) The message to display if the assertion fails.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method isFunction
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync isFunction : function (actual /*:Object*/, message /*:String*/) /*:Void*/ {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync throw new Y.Assert.UnexpectedValue(Y.Assert._formatMessage(message, "Value should be a function."), actual);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Asserts that a value is an instance of a particular object. This may return
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * incorrect results when comparing objects from one frame to constructors in
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync * another frame. For best results, don't use in a cross-frame manner.
af0a09edb4c1431b606fe207d4138da008f67f13vboxsync * @param {Function} expected The function that the object should be an instance of.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} actual The object to test.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {String} message (Optional) The message to display if the assertion fails.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method isInstanceOf
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync isInstanceOf : function (expected /*:Function*/, actual /*:Object*/, message /*:String*/) /*:Void*/ {
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync throw new Y.Assert.ComparisonFailure(Y.Assert._formatMessage(message, "Value isn't an instance of expected type."), expected, actual);
564cc620447c495b6ff9cbb9274e225692fe38dfvboxsync * Asserts that a value is a number.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} actual The value to test.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {String} message (Optional) The message to display if the assertion fails.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method isNumber
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync isNumber : function (actual /*:Object*/, message /*:String*/) /*:Void*/ {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync throw new Y.Assert.UnexpectedValue(Y.Assert._formatMessage(message, "Value should be a number."), actual);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Asserts that a value is an object.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} actual The value to test.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {String} message (Optional) The message to display if the assertion fails.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method isObject
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync isObject : function (actual /*:Object*/, message /*:String*/) /*:Void*/ {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync throw new Y.Assert.UnexpectedValue(Y.Assert._formatMessage(message, "Value should be an object."), actual);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Asserts that a value is a string.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} actual The value to test.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {String} message (Optional) The message to display if the assertion fails.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method isString
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync isString : function (actual /*:Object*/, message /*:String*/) /*:Void*/ {
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync throw new Y.Assert.UnexpectedValue(Y.Assert._formatMessage(message, "Value should be a string."), actual);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Asserts that a value is of a particular type.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {String} expectedType The expected type of the variable.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} actualValue The actual value to test.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {String} message (Optional) The message to display if the assertion fails.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method isTypeOf
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync isTypeOf : function (expectedType /*:String*/, actualValue /*:Object*/, message /*:String*/) /*:Void*/{
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync throw new Y.Assert.ComparisonFailure(Y.Assert._formatMessage(message, "Value should be of type " + expectedType + "."), expected, typeof actualValue);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Asserts that a given condition is true. If not, then a Y.Assert.Error object is thrown
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * and the test fails.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method Y.assert
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Boolean} condition The condition to test.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {String} message The message to display if the assertion fails.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync throw new Y.Assert.Error(Y.Assert._formatMessage(message, "Assertion failed."));
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-----------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync // Assertion errors
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //-----------------------------------------------------------------------------
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Error is thrown whenever an assertion fails. It provides methods
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * to more easily get at error information and also provides a base class
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * from which more specific assertion errors can be derived.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {String} message The message to display when the error occurs.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @namespace Assert
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @class Error
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @constructor
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //call superclass
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync arguments.callee.superclass.constructor.call(this, message);
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Error message. Must be duplicated to ensure browser receives it.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @type String
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @property message
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * The name of the error that occurred.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @type String
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @property name
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //inherit methods
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Returns a fully formatted error for an assertion failure. This should
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * be overridden by all subclasses to provide specific information.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method getMessage
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @return {String} A string describing the error.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return this.message;
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Returns a string representation of the error.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method toString
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @return {String} A string representation of the error.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * Returns a primitive value version of the error. Same as toString().
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @method valueOf
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @return {String} A primitive value version of the error.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync return this.toString();
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * ComparisonFailure is subclass of Error that is thrown whenever
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * a comparison between two values fails. It provides mechanisms to retrieve
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * both the expected and actual value.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {String} message The message to display when the error occurs.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} expected The expected value.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @param {Object} actual The actual value that caused the assertion to fail.
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @namespace Assert
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @extends Assert.Error
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @class ComparisonFailure
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync * @constructor
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync Y.Assert.ComparisonFailure = function (message /*:String*/, expected /*:Object*/, actual /*:Object*/){
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync //call superclass
30a23dfc653298a09d77d3045cf873b1bd6ddecfvboxsync arguments.callee.superclass.constructor.call(this, message);
arguments.callee.superclass.constructor.call(this, message || "This test should have thrown an error but didn't.");
Y.ArrayAssert = {
Y.Assert.fail(Y.Assert._formatMessage(message, "Value " + needle + " (" + (typeof needle) + ") not found in array [" + haystack + "]."));
Y.Assert.fail(Y.Assert._formatMessage(message, "Value " + needles[i] + " (" + (typeof needles[i]) + ") not found in array [" + haystack + "]."));
indexOf : function (needle /*:Object*/, haystack /*:Array*/, index /*:int*/, message /*:String*/) /*:Void*/ {
if (index != i){
Y.Assert.fail(Y.Assert._formatMessage(message, "Value exists at index " + i + " but should be at index " + index + "."));
Y.Assert.fail(Y.Assert._formatMessage(message, "Value doesn't exist in array [" + haystack + "]."));
Y.Assert.fail(Y.Assert._formatMessage(message, "Array should have a length of " + expected.length + " but has a length of " + actual.length));
throw new Y.Assert.ComparisonFailure(Y.Assert._formatMessage(message, "Values in position " + i + " are not equal."), expected[i], actual[i]);
Y.Assert.fail(Y.Assert._formatMessage(message, "Array should have a length of " + expected.length + " but has a length of " + actual.length));
throw new Y.Assert.ComparisonFailure(Y.Assert._formatMessage(message, "Values in position " + i + " are not equivalent."), expected[i], actual[i]);
Y.Assert.fail(Y.Assert._formatMessage(message, "Array should have a length of " + expected.length + " but has a length of " + actual.length));
throw new Y.Assert.ComparisonFailure(Y.Assert._formatMessage(message, "Values in position " + i + " are not the same."), expected[i], actual[i]);
lastIndexOf : function (needle /*:Object*/, haystack /*:Array*/, index /*:int*/, message /*:String*/) /*:Void*/ {
if (index != i){
Y.Assert.fail(Y.Assert._formatMessage(message, "Value exists at index " + i + " but should be at index " + index + "."));
Y.ObjectAssert = {
throw new Y.Assert.ComparisonFailure(Y.Assert._formatMessage(message, "Values should be equal for property " + name), expected[name], actual[name]);
Y.Assert.fail(Y.Assert._formatMessage(message, "Property '" + propertyName + "' not found on object."));
Y.Assert.fail(Y.Assert._formatMessage(message, "Property '" + propertyName + "' not found on object instance."));
* Asserts that all properties on a given object also exist on an object instance (not on its prototype).
Y.Assert.fail(Y.Assert._formatMessage(message, "Property '" + name + "' not found on object instance."));
Y.DateAssert = {
throw new TypeError("DateY.AsserttimesAreEqual(): Expected and actual values must be Date objects.");
var l = Y.Lang;
var xml /*:String*/ = "<" + results.type + " name=\"" + results.name.replace(/"/g, """).replace(/'/g, "'") + "\"";
xml += " passed=\"" + results.passed + "\" failed=\"" + results.failed + "\" ignored=\"" + results.ignored + "\" total=\"" + results.total + "\">";
return xml;
* Default is Y.Test.Format.XML.
this._fields = new Object();
if (this._form){
this._form = null;
if (this._iframe){
this._iframe = null;
this._fields = null;
if (!this._form){
var mock = null;
} catch (ex) {
mock = {};
return mock;
array[i] = Y.Mock.Value(Y.Assert.areSame, [arg], "Argument " + i + " of " + name + "() is incorrect.");
Y.Assert.areEqual(args.length, arguments.length, "Method " + name + "() passed incorrect number of arguments.");
if (args[i]){
if (error){
throw error;
return result;
Y.Assert.areEqual(expectation.callCount, expectation.actualCallCount, "Method " + expectation.method + "() wasn't called the expected number of times.");
Y.Assert.areEqual(expectation.value, mock[expectation.property], "Property " + expectation.property + " wasn't set to the correct value.");