diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index cd744f21..1976a797 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -3755,18 +3755,18 @@ getJasmineRequireObj().toThrowError = function(j$) { var expected = null, errorType = null; - if (arguments.length == 2) { - expected = arguments[1]; - if (isAnErrorType(expected)) { - errorType = expected; - expected = null; - } - } else if (arguments.length > 2) { + if (arguments[2]) { errorType = arguments[1]; expected = arguments[2]; if (!isAnErrorType(errorType)) { throw new Error(getErrorMsg('Expected error type is not an Error.')); } + } else if (arguments[1]) { + expected = arguments[1]; + if (isAnErrorType(expected)) { + errorType = expected; + expected = null; + } } if (expected && !isStringOrRegExp(expected)) { diff --git a/src/core/matchers/toThrowError.js b/src/core/matchers/toThrowError.js index ef809e35..7cdc1d9f 100644 --- a/src/core/matchers/toThrowError.js +++ b/src/core/matchers/toThrowError.js @@ -71,18 +71,18 @@ getJasmineRequireObj().toThrowError = function(j$) { var expected = null, errorType = null; - if (arguments.length == 2) { - expected = arguments[1]; - if (isAnErrorType(expected)) { - errorType = expected; - expected = null; - } - } else if (arguments.length > 2) { + if (arguments[2]) { errorType = arguments[1]; expected = arguments[2]; if (!isAnErrorType(errorType)) { throw new Error(getErrorMsg('Expected error type is not an Error.')); } + } else if (arguments[1]) { + expected = arguments[1]; + if (isAnErrorType(expected)) { + errorType = expected; + expected = null; + } } if (expected && !isStringOrRegExp(expected)) {