jcouyang / closure-library

Automatically exported from code.google.com/p/closure-library
0 stars 0 forks source link

goog.asserts.AssertionError is not compatible in ExpectedFailures.js #575

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

What steps will reproduce the problem?
1. Create a UnitTest with ExpectedFailures and test with 
goog.asserts.AssertionError
2. Run the test

What is the expected output? What do you see instead?
The test throws an error that AssertionError is not expected.
In some cases it's very useful to catch such AssertError, i.e. for classes that 
have goog.asserts.assert() implemented with additional errormessage parameters.

I made a temporary local fix for this in ExpectedFailures.isExceptionExpected():

{code}
/**
 * Determines if the given exception was expected.
 * @param {Object} ex The exception to check.
 * @return {boolean} Whether the exception was expected.
 */
goog.testing.ExpectedFailures.prototype.isExceptionExpected = function(ex) {

  //return this.expectingFailure_ && ex instanceof goog.testing.JsUnitException;

   //Extended for goog.asserts.AssertionError!
  return this.expectingFailure_
      && (ex instanceof goog.testing.JsUnitException || ex instanceof goog.asserts.AssertionError);
};
{code}

What version of the product are you using? On what operating system?

Please provide any additional information below.

Note: we cannot accept patches without the contributor license agreement
being signed. See http://code.google.com/p/closure-
library/wiki/Contributors for more info.

Original issue reported on code.google.com by atng...@gmail.com on 24 Jul 2013 at 9:14