33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * ComparisonFailure is subclass of Error that is thrown whenever
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * a comparison between two values fails. It provides mechanisms to retrieve
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * both the expected and actual value.
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * @param {String} message The message to display when the error occurs.
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * @param {Object} expected The expected value.
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * @param {Object} actual The actual value that caused the assertion to fail.
5aab19b8b78189ce79cf89283f2d505566d4e6a8Dav Glass * @namespace Test
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * @extends AssertionError
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * @class ComparisonFailure
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * @constructor
d0199bcbfc68b65683c19c4e3e0c38e238142e7eDav GlassYUITest.ComparisonFailure = function (message, expected, actual){
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass //call superclass
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * The expected value.
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * @type Object
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * @property expected
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * The actual value.
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * @type Object
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * @property actual
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * The name of the error that occurred.
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * @type String
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * @property name
d0199bcbfc68b65683c19c4e3e0c38e238142e7eDav Glass//inherit from YUITest.AssertionError
d0199bcbfc68b65683c19c4e3e0c38e238142e7eDav GlassYUITest.ComparisonFailure.prototype = new YUITest.AssertionError;
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass//restore constructor
d0199bcbfc68b65683c19c4e3e0c38e238142e7eDav GlassYUITest.ComparisonFailure.prototype.constructor = YUITest.ComparisonFailure;
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * Returns a fully formatted error for an assertion failure. This message
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * provides information about the expected and actual values.
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * @method getMessage
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * @return {String} A string describing the error.
d0199bcbfc68b65683c19c4e3e0c38e238142e7eDav GlassYUITest.ComparisonFailure.prototype.getMessage = function(){
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass return this.message + "\nExpected: " + this.expected + " (" + (typeof this.expected) + ")" +
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass "\nActual: " + this.actual + " (" + (typeof this.actual) + ")";