Better stack trace on exception. Better results if exception is due to true exception

This commit is contained in:
Davis W. Frank 2011-06-01 21:14:59 -07:00
parent da297d0f56
commit ba10d178b2
3 changed files with 45 additions and 25 deletions

View File

@ -97,9 +97,10 @@ jasmine.ExpectationResult = function(params) {
this.passed_ = params.passed;
this.expected = params.expected;
this.actual = params.actual;
this.message = this.passed_ ? 'Passed.' : params.message;
this.trace = this.passed_ ? '' : new Error(this.message);
var trace = params.trace || new Error(this.message);
this.trace = this.passed_ ? '' : trace;
};
jasmine.ExpectationResult.prototype.toString = function () {
@ -597,10 +598,18 @@ jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
return null;
}
var xhr = tryIt(function(){return new ActiveXObject("Msxml2.XMLHTTP.6.0");}) ||
tryIt(function(){return new ActiveXObject("Msxml2.XMLHTTP.3.0");}) ||
tryIt(function(){return new ActiveXObject("Msxml2.XMLHTTP");}) ||
tryIt(function(){return new ActiveXObject("Microsoft.XMLHTTP");});
var xhr = tryIt(function() {
return new ActiveXObject("Msxml2.XMLHTTP.6.0");
}) ||
tryIt(function() {
return new ActiveXObject("Msxml2.XMLHTTP.3.0");
}) ||
tryIt(function() {
return new ActiveXObject("Msxml2.XMLHTTP");
}) ||
tryIt(function() {
return new ActiveXObject("Microsoft.XMLHTTP");
});
if (!xhr) throw new Error("This browser does not support XMLHttpRequest.");
@ -1999,7 +2008,8 @@ jasmine.Spec.prototype.waitsFor = function(latchFunction, optional_timeoutMessag
jasmine.Spec.prototype.fail = function (e) {
var expectationResult = new jasmine.ExpectationResult({
passed: false,
message: e ? jasmine.util.formatException(e) : 'Exception'
message: e ? jasmine.util.formatException(e) : 'Exception',
trace: { stack: e.stack }
});
this.results_.addResult(expectationResult);
};
@ -2458,5 +2468,5 @@ jasmine.version_= {
"major": 1,
"minor": 1,
"build": 0,
"revision": 1306336386
"revision": 1306942160
};

View File

@ -120,7 +120,8 @@ jasmine.Spec.prototype.waitsFor = function(latchFunction, optional_timeoutMessag
jasmine.Spec.prototype.fail = function (e) {
var expectationResult = new jasmine.ExpectationResult({
passed: false,
message: e ? jasmine.util.formatException(e) : 'Exception'
message: e ? jasmine.util.formatException(e) : 'Exception',
trace: { stack: e.stack }
});
this.results_.addResult(expectationResult);
};

View File

@ -97,9 +97,10 @@ jasmine.ExpectationResult = function(params) {
this.passed_ = params.passed;
this.expected = params.expected;
this.actual = params.actual;
this.message = this.passed_ ? 'Passed.' : params.message;
this.trace = this.passed_ ? '' : new Error(this.message);
var trace = (params.trace || new Error(this.message));
this.trace = this.passed_ ? '' : trace;
};
jasmine.ExpectationResult.prototype.toString = function () {
@ -597,10 +598,18 @@ jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
return null;
}
var xhr = tryIt(function(){return new ActiveXObject("Msxml2.XMLHTTP.6.0");}) ||
tryIt(function(){return new ActiveXObject("Msxml2.XMLHTTP.3.0");}) ||
tryIt(function(){return new ActiveXObject("Msxml2.XMLHTTP");}) ||
tryIt(function(){return new ActiveXObject("Microsoft.XMLHTTP");});
var xhr = tryIt(function() {
return new ActiveXObject("Msxml2.XMLHTTP.6.0");
}) ||
tryIt(function() {
return new ActiveXObject("Msxml2.XMLHTTP.3.0");
}) ||
tryIt(function() {
return new ActiveXObject("Msxml2.XMLHTTP");
}) ||
tryIt(function() {
return new ActiveXObject("Microsoft.XMLHTTP");
});
if (!xhr) throw new Error("This browser does not support XMLHttpRequest.");