Simplifying toThrow:

- It still supports no expected, which means that something was thrown
- Expected value is now tested via equality in order to pass

Adding toThrowError:
- toThrowError() passes if an Error type was thrown
- toThrowError(String) & toThrowError(RegExp) compare Expected to the Error message
- toThrowError(Error constructor) compares Expected to the constructor of what was thrown
- toThrowError(Error constructor, String) & toThrowError(Error constructor, RegExp) compares both the Error and the message

Also, equality now handles Errors, enforcing the message as part of the equality.
This commit is contained in:
Davis W. Frank
2013-06-03 09:24:43 -07:00
parent 9e31201f1a
commit 0ac497db6b
8 changed files with 611 additions and 188 deletions

View File

@@ -79,7 +79,9 @@ getJasmineRequireObj().matchersUtil = function(j$) {
}
}
if (a instanceof Error && b instanceof Error) {
return a.message == b.message;
}
// Identical objects are equal. `0 === -0`, but they aren't identical.
// See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).