Remove jasmine.CATCH_EXCEPTIONS

- HTMLReporters should be rewritten to make this sort of thing easier.
- Fix HTMLReporter try/catch switch
- We can't really call resultCallback & throw, so that's been reverted
  for now.
This commit is contained in:
Rajan Agaskar
2012-12-07 17:26:59 -08:00
parent 98c99c4ebb
commit 43552494ee
15 changed files with 78 additions and 84 deletions

View File

@@ -9,6 +9,7 @@
var self = this;
var global = options.global || jasmine.getGlobal();
var catchExceptions = true;
var encourageGC = options.encourageGarbageCollection || encourageGarbageCollection;
this.clock = new jasmine.Clock(global, new jasmine.DelayedFunctionScheduler());
@@ -21,7 +22,6 @@
this.currentRunner_ = new jasmine.Runner(this, isSuite);
this.spies_ = [];
this.currentSpec = null;
this.catchExceptions = jasmine.CATCH_EXCEPTIONS;
this.undefined = jasmine.undefined;
this.reporter = new jasmine.MultiReporter();
@@ -87,6 +87,14 @@
return buildExpectationResult(attrs);
};
this.catchExceptions = function(value) {
return catchExceptions = !!value;
}
this.catchingExceptions = function(value) {
return catchExceptions;
}
this.specFactory = function(description, fn, suite) {
var spec = new specConstructor({
id: self.nextSpecId(),
@@ -98,7 +106,7 @@
getSpecName: function(spec) { return getSpecName(spec, suite) },
startCallback: startCallback,
description: description,
catchExceptions: self.catchExceptions,
catchingExceptions: this.catchingExceptions,
expectationResultFactory: expectationResultFactory,
fn: fn
});

View File

@@ -8,7 +8,7 @@ jasmine.Spec = function(attrs) {
this.fn = attrs.fn;
this.beforeFns = attrs.beforeFns || function() {};
this.afterFns = attrs.afterFns || function() {};
this.catchExceptions = attrs.catchExceptions;
this.catchingExceptions = attrs.catchingExceptions;
this.startCallback = attrs.startCallback || function() {};
this.exceptionFormatter = attrs.exceptionFormatter || function() {};
this.getSpecName = attrs.getSpecName;
@@ -54,8 +54,9 @@ jasmine.Spec.prototype.execute = function() {
message: self.exceptionFormatter(e),
trace: e
}));
if (!self.catchExceptions) {
resultCallback();
if (!self.catchingExceptions()) {
//TODO: set a var when we catch an exception and
//use a finally block to close the loop in a nice way..
throw e;
}
}

View File

@@ -46,13 +46,6 @@ jasmine.MAX_PRETTY_PRINT_DEPTH = 40;
*/
jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;
/**
* By default exceptions thrown in the context of a test are caught by jasmine so that it can run the remaining tests in the suite.
* Set to false to let the exception bubble up in the browser.
*
*/
jasmine.CATCH_EXCEPTIONS = true;
jasmine.getGlobal = function() {
function getGlobal() {
return this;