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

@ -80,7 +80,7 @@ jasmine.MessageResult = function(values) {
jasmine.MessageResult.prototype.toString = function() { jasmine.MessageResult.prototype.toString = function() {
var text = ""; var text = "";
for(var i = 0; i < this.values.length; i++) { for (var i = 0; i < this.values.length; i++) {
if (i > 0) text += " "; if (i > 0) text += " ";
if (jasmine.isString_(this.values[i])) { if (jasmine.isString_(this.values[i])) {
text += this.values[i]; text += this.values[i];
@ -97,9 +97,10 @@ jasmine.ExpectationResult = function(params) {
this.passed_ = params.passed; this.passed_ = params.passed;
this.expected = params.expected; this.expected = params.expected;
this.actual = params.actual; this.actual = params.actual;
this.message = this.passed_ ? 'Passed.' : params.message; 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 () { jasmine.ExpectationResult.prototype.toString = function () {
@ -597,10 +598,18 @@ jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
return null; return null;
} }
var xhr = tryIt(function(){return new ActiveXObject("Msxml2.XMLHTTP.6.0");}) || var xhr = tryIt(function() {
tryIt(function(){return new ActiveXObject("Msxml2.XMLHTTP.3.0");}) || return new ActiveXObject("Msxml2.XMLHTTP.6.0");
tryIt(function(){return new ActiveXObject("Msxml2.XMLHTTP");}) || }) ||
tryIt(function(){return new ActiveXObject("Microsoft.XMLHTTP");}); 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."); 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) { jasmine.Spec.prototype.fail = function (e) {
var expectationResult = new jasmine.ExpectationResult({ var expectationResult = new jasmine.ExpectationResult({
passed: false, passed: false,
message: e ? jasmine.util.formatException(e) : 'Exception' message: e ? jasmine.util.formatException(e) : 'Exception',
trace: { stack: e.stack }
}); });
this.results_.addResult(expectationResult); this.results_.addResult(expectationResult);
}; };
@ -2458,5 +2468,5 @@ jasmine.version_= {
"major": 1, "major": 1,
"minor": 1, "minor": 1,
"build": 0, "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) { jasmine.Spec.prototype.fail = function (e) {
var expectationResult = new jasmine.ExpectationResult({ var expectationResult = new jasmine.ExpectationResult({
passed: false, passed: false,
message: e ? jasmine.util.formatException(e) : 'Exception' message: e ? jasmine.util.formatException(e) : 'Exception',
trace: { stack: e.stack }
}); });
this.results_.addResult(expectationResult); this.results_.addResult(expectationResult);
}; };

View File

@ -80,7 +80,7 @@ jasmine.MessageResult = function(values) {
jasmine.MessageResult.prototype.toString = function() { jasmine.MessageResult.prototype.toString = function() {
var text = ""; var text = "";
for(var i = 0; i < this.values.length; i++) { for (var i = 0; i < this.values.length; i++) {
if (i > 0) text += " "; if (i > 0) text += " ";
if (jasmine.isString_(this.values[i])) { if (jasmine.isString_(this.values[i])) {
text += this.values[i]; text += this.values[i];
@ -97,9 +97,10 @@ jasmine.ExpectationResult = function(params) {
this.passed_ = params.passed; this.passed_ = params.passed;
this.expected = params.expected; this.expected = params.expected;
this.actual = params.actual; this.actual = params.actual;
this.message = this.passed_ ? 'Passed.' : params.message; 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 () { jasmine.ExpectationResult.prototype.toString = function () {
@ -597,10 +598,18 @@ jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
return null; return null;
} }
var xhr = tryIt(function(){return new ActiveXObject("Msxml2.XMLHTTP.6.0");}) || var xhr = tryIt(function() {
tryIt(function(){return new ActiveXObject("Msxml2.XMLHTTP.3.0");}) || return new ActiveXObject("Msxml2.XMLHTTP.6.0");
tryIt(function(){return new ActiveXObject("Msxml2.XMLHTTP");}) || }) ||
tryIt(function(){return new ActiveXObject("Microsoft.XMLHTTP");}); 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."); if (!xhr) throw new Error("This browser does not support XMLHttpRequest.");