API Docs for: 3.10.3
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.  
  17. //call superclass
  18. YUITest.AssertionError.call(this, message);
  19. /**
  20. * The unexpected value.
  21. * @type Object
  22. * @property unexpected
  23. */
  24. this.unexpected = unexpected;
  25. /**
  26. * The name of the error that occurred.
  27. * @type String
  28. * @property name
  29. */
  30. this.name = "UnexpectedValue";
  31. };
  32.  
  33. //inherit from YUITest.AssertionError
  34. YUITest.UnexpectedValue.prototype = new YUITest.AssertionError();
  35.  
  36. //restore constructor
  37. YUITest.UnexpectedValue.prototype.constructor = YUITest.UnexpectedValue;
  38.  
  39. /**
  40. * Returns a fully formatted error for an assertion failure. This message
  41. * provides information about the expected and actual values.
  42. * @method getMessage
  43. * @return {String} A string describing the error.
  44. */
  45. YUITest.UnexpectedValue.prototype.getMessage = function(){
  46. return this.message + "\nUnexpected: " + this.unexpected + " (" + (typeof this.unexpected) + ") ";
  47. };
  48.