API Docs for: 3.8.0
Show:

File: test/js/UnexpectedValue.js

  1. /**
  2.  * UnexpectedValue is subclass of Error that is thrown whenever
  3.  * a value was unexpected in its scope. This typically means that a test
  4.  * was performed to determine that a value was *not* equal to a certain
  5.  * value.
  6.  *
  7.  * @param {String} message The message to display when the error occurs.
  8.  * @param {Object} unexpected The unexpected value.
  9.  * @namespace Test
  10.  * @extends AssertionError
  11.  * @module test
  12.  * @class UnexpectedValue
  13.  * @constructor
  14.  */
  15. YUITest.UnexpectedValue = function (message, unexpected){

  16.     //call superclass
  17.     YUITest.AssertionError.call(this, message);
  18.    
  19.     /**
  20.      * The unexpected value.
  21.      * @type Object
  22.      * @property unexpected
  23.      */
  24.     this.unexpected = unexpected;
  25.    
  26.     /**
  27.      * The name of the error that occurred.
  28.      * @type String
  29.      * @property name
  30.      */
  31.     this.name = "UnexpectedValue";
  32.    
  33. };

  34. //inherit from YUITest.AssertionError
  35. YUITest.UnexpectedValue.prototype = new YUITest.AssertionError();

  36. //restore constructor
  37. YUITest.UnexpectedValue.prototype.constructor = YUITest.UnexpectedValue;

  38. /**
  39.  * Returns a fully formatted error for an assertion failure. This message
  40.  * provides information about the expected and actual values.
  41.  * @method getMessage
  42.  * @return {String} A string describing the error.
  43.  */
  44. YUITest.UnexpectedValue.prototype.getMessage = function(){
  45.     return this.message + "\nUnexpected: " + this.unexpected + " (" + (typeof this.unexpected) + ") ";
  46. };

  47.