Merge branch 'master' into 3.0-features

This commit is contained in:
Steve Gravrock
2017-12-18 09:48:17 -08:00
9 changed files with 167 additions and 31 deletions

View File

@@ -59,6 +59,10 @@ getJasmineRequireObj().pp = function(j$) {
} else {
this.emitScalar(value.toString());
}
} catch (e) {
if (this.ppNestLevel_ > 1 || !(e instanceof MaxCharsReachedError)) {
throw e;
}
} finally {
this.ppNestLevel_--;
}
@@ -95,6 +99,7 @@ getJasmineRequireObj().pp = function(j$) {
function StringPrettyPrinter() {
PrettyPrinter.call(this);
this.length = 0;
this.stringParts = [];
}
@@ -250,9 +255,31 @@ getJasmineRequireObj().pp = function(j$) {
};
StringPrettyPrinter.prototype.append = function(value) {
this.stringParts.push(value);
var result = truncate(value, j$.MAX_PRETTY_PRINT_CHARS - this.length);
this.length += result.value.length;
this.stringParts.push(result.value);
if (result.truncated) {
throw new MaxCharsReachedError();
}
};
function truncate(s, maxlen) {
if (s.length <= maxlen) {
return { value: s, truncated: false };
}
s = s.substring(0, maxlen - 4) + ' ...';
return { value: s, truncated: true };
}
function MaxCharsReachedError() {
this.message = 'Exceeded ' + j$.MAX_PRETTY_PRINT_CHARS +
' characters while pretty-printing a value';
}
MaxCharsReachedError.prototype = new Error();
function keys(obj, isArray) {
var allKeys = Object.keys ? Object.keys(obj) :
(function(o) {

View File

@@ -125,7 +125,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
var maybeThenable = queueableFn.fn.call(self.userContext);
if (maybeThenable && j$.isFunction_(maybeThenable.then)) {
maybeThenable.then(next, next.fail);
maybeThenable.then(next, onPromiseRejection);
completedSynchronously = false;
return { completedSynchronously: false };
}
@@ -147,6 +147,11 @@ getJasmineRequireObj().QueueRunner = function(j$) {
errored = true;
}
function onPromiseRejection(e) {
onException(e);
next();
}
function handleException(e, queueableFn) {
onException(e);
if (!self.catchException(e)) {

View File

@@ -8,14 +8,20 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
* Set this to a lower value to speed up pretty printing if you have large objects.
* @name jasmine.MAX_PRETTY_PRINT_DEPTH
*/
j$.MAX_PRETTY_PRINT_DEPTH = 40;
j$.MAX_PRETTY_PRINT_DEPTH = 8;
/**
* Maximum number of array elements to display when pretty printing objects.
* This will also limit the number of keys and values displayed for an object.
* Elements past this number will be ellipised.
* @name jasmine.MAX_PRETTY_PRINT_ARRAY_LENGTH
*/
j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = 100;
j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = 50;
/**
* Maximum number of charasters to display when pretty printing objects.
* Characters past this number will be ellipised.
* @name jasmine.MAX_PRETTY_PRINT_CHARS
*/
j$.MAX_PRETTY_PRINT_CHARS = 1000;
/**
* Default number of milliseconds Jasmine will wait for an asynchronous spec to complete.
* @name jasmine.DEFAULT_TIMEOUT_INTERVAL