assert: handle class constructors in throws()
Currently, if a class constructor is passed as the expected value to throws()
, and a match is not received, the code falls through to the validation function case, which uses fn.prototype.call()
. Class constructors must be called with new
, so this throws a TypeError
. This commit adds a try...catch
, which handles the thrown error.
I'm proposing this as an alternative to #4166. The drawback I see with #4166 is that it only handles classes which extend Error
. In general, it might be a good thing to wrap user defined validation functions in a try...catch
anyway. Closes #3188 (closed).