Merge branch 'better-array-errors' of https://github.com/majidmade/jasmine

- Merges #1527 from @majidmade
- Fixes #1485
This commit is contained in:
Steve Gravrock
2018-03-10 07:40:08 -08:00
3 changed files with 85 additions and 8 deletions

View File

@@ -3045,8 +3045,14 @@ getJasmineRequireObj().matchersUtil = function(j$) {
});
for (i = 0; i < aLength || i < bLength; i++) {
var formatter = false;
diffBuilder.withPath(i, function() {
result = eq(i < aLength ? a[i] : void 0, i < bLength ? b[i] : void 0, aStack, bStack, customTesters, diffBuilder) && result;
if (i >= bLength) {
diffBuilder.record(a[i], void 0, actualArrayIsLongerFormatter);
result = false;
} else {
result = eq(i < aLength ? a[i] : void 0, i < bLength ? b[i] : void 0, aStack, bStack, customTesters, diffBuilder) && result;
}
});
}
if (!result) {
@@ -3272,6 +3278,13 @@ getJasmineRequireObj().matchersUtil = function(j$) {
', but was ' + j$.pp(actual) + '.';
}
function actualArrayIsLongerFormatter(actual, expected, path) {
return 'Unexpected ' +
path + (path.depth() ? ' = ' : '') +
j$.pp(actual) +
' in array.';
}
function formatKeyValuePairs(obj) {
var formatted = '';
for (var key in obj) {