Merge branch 'master' into 3.0-features
This commit is contained in:
@@ -124,6 +124,7 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) {
|
||||
}
|
||||
|
||||
do {
|
||||
deletedKeys = [];
|
||||
var newCurrentTime = scheduledLookup.shift();
|
||||
tickDate(newCurrentTime - currentTime);
|
||||
|
||||
|
||||
@@ -40,9 +40,9 @@ getJasmineRequireObj().pp = function(j$) {
|
||||
this.emitScalar('HTMLNode');
|
||||
} else if (value instanceof Date) {
|
||||
this.emitScalar('Date(' + value + ')');
|
||||
} else if (j$.getType_(value) == '[object Set]') {
|
||||
} else if (j$.isSet(value)) {
|
||||
this.emitSet(value);
|
||||
} else if (j$.getType_(value) == '[object Map]') {
|
||||
} else if (j$.isMap(value)) {
|
||||
this.emitMap(value);
|
||||
} else if (j$.isTypedArray_(value)) {
|
||||
this.emitTypedArray(value);
|
||||
@@ -139,13 +139,18 @@ getJasmineRequireObj().pp = function(j$) {
|
||||
}
|
||||
this.append('Set( ');
|
||||
var size = Math.min(set.size, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH);
|
||||
var iter = set.values();
|
||||
for (var i = 0; i < size; i++) {
|
||||
var i = 0;
|
||||
set.forEach( function( value, key ) {
|
||||
if (i >= size) {
|
||||
return;
|
||||
}
|
||||
if (i > 0) {
|
||||
this.append(', ');
|
||||
}
|
||||
this.format(iter.next().value);
|
||||
}
|
||||
this.format(value);
|
||||
|
||||
i++;
|
||||
}, this );
|
||||
if (set.size > size){
|
||||
this.append(', ...');
|
||||
}
|
||||
@@ -159,13 +164,18 @@ getJasmineRequireObj().pp = function(j$) {
|
||||
}
|
||||
this.append('Map( ');
|
||||
var size = Math.min(map.size, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH);
|
||||
var iter = map.entries();
|
||||
for (var i = 0; i < size; i++) {
|
||||
var i = 0;
|
||||
map.forEach( function( value, key ) {
|
||||
if (i >= size) {
|
||||
return;
|
||||
}
|
||||
if (i > 0) {
|
||||
this.append(', ');
|
||||
}
|
||||
this.format(iter.next().value);
|
||||
}
|
||||
this.format([key,value]);
|
||||
|
||||
i++;
|
||||
}, this );
|
||||
if (map.size > size){
|
||||
this.append(', ...');
|
||||
}
|
||||
|
||||
@@ -104,6 +104,14 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
return obj.nodeType > 0;
|
||||
};
|
||||
|
||||
j$.isMap = function(obj) {
|
||||
return typeof jasmineGlobal.Map !== 'undefined' && obj.constructor === jasmineGlobal.Map;
|
||||
};
|
||||
|
||||
j$.isSet = function(obj) {
|
||||
return typeof jasmineGlobal.Set !== 'undefined' && obj.constructor === jasmineGlobal.Set;
|
||||
};
|
||||
|
||||
j$.isPromise = function(obj) {
|
||||
return typeof jasmineGlobal.Promise !== 'undefined' && obj.constructor === jasmineGlobal.Promise;
|
||||
};
|
||||
|
||||
@@ -192,7 +192,7 @@ getJasmineRequireObj().matchersUtil = function(j$) {
|
||||
diffBuilder.record(a, b);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
var aIsPromise = j$.isPromise(a);
|
||||
var bIsPromise = j$.isPromise(b);
|
||||
if (aIsPromise && bIsPromise) {
|
||||
@@ -232,26 +232,34 @@ getJasmineRequireObj().matchersUtil = function(j$) {
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
} else if (className == '[object Map]') {
|
||||
} else if (j$.isMap(a) && j$.isMap(b)) {
|
||||
if (a.size != b.size) {
|
||||
diffBuilder.record(a, b);
|
||||
return false;
|
||||
}
|
||||
|
||||
var keysA = [];
|
||||
var keysB = [];
|
||||
a.forEach( function( valueA, keyA ) {
|
||||
keysA.push( keyA );
|
||||
});
|
||||
b.forEach( function( valueB, keyB ) {
|
||||
keysB.push( keyB );
|
||||
});
|
||||
|
||||
// For both sets of keys, check they map to equal values in both maps.
|
||||
// Keep track of corresponding keys (in insertion order) in order to handle asymmetric obj keys.
|
||||
var mapKeys = [a.keys(), b.keys()];
|
||||
var cmpKeys = [b.keys(), a.keys()];
|
||||
var mapIter, mapKeyIt, mapKey, mapValueA, mapValueB;
|
||||
var cmpIter, cmpKeyIt, cmpKey;
|
||||
var mapKeys = [keysA, keysB];
|
||||
var cmpKeys = [keysB, keysA];
|
||||
var mapIter, mapKey, mapValueA, mapValueB;
|
||||
var cmpIter, cmpKey;
|
||||
for (i = 0; result && i < mapKeys.length; i++) {
|
||||
mapIter = mapKeys[i];
|
||||
cmpIter = cmpKeys[i];
|
||||
mapKeyIt = mapIter.next();
|
||||
cmpKeyIt = cmpIter.next();
|
||||
while (result && !mapKeyIt.done) {
|
||||
mapKey = mapKeyIt.value;
|
||||
cmpKey = cmpKeyIt.value;
|
||||
|
||||
for (var j = 0; result && j < mapIter.length; j++) {
|
||||
mapKey = mapIter[j];
|
||||
cmpKey = cmpIter[j];
|
||||
mapValueA = a.get(mapKey);
|
||||
|
||||
// Only use the cmpKey when one of the keys is asymmetric and the corresponding key matches,
|
||||
@@ -264,8 +272,6 @@ getJasmineRequireObj().matchersUtil = function(j$) {
|
||||
mapValueB = b.get(mapKey);
|
||||
}
|
||||
result = eq(mapValueA, mapValueB, aStack, bStack, customTesters, j$.NullDiffBuilder());
|
||||
mapKeyIt = mapIter.next();
|
||||
cmpKeyIt = cmpIter.next();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,48 +279,49 @@ getJasmineRequireObj().matchersUtil = function(j$) {
|
||||
diffBuilder.record(a, b);
|
||||
return false;
|
||||
}
|
||||
} else if (className == '[object Set]') {
|
||||
} else if (j$.isSet(a) && j$.isSet(b)) {
|
||||
if (a.size != b.size) {
|
||||
diffBuilder.record(a, b);
|
||||
return false;
|
||||
}
|
||||
|
||||
var valuesA = [];
|
||||
a.forEach( function( valueA ) {
|
||||
valuesA.push( valueA );
|
||||
});
|
||||
var valuesB = [];
|
||||
b.forEach( function( valueB ) {
|
||||
valuesB.push( valueB );
|
||||
});
|
||||
|
||||
// For both sets, check they are all contained in the other set
|
||||
var setPairs = [[a, b], [b, a]];
|
||||
var setPairs = [[valuesA, valuesB], [valuesB, valuesA]];
|
||||
var stackPairs = [[aStack, bStack], [bStack, aStack]];
|
||||
var baseIter, baseValueIt, baseValue, baseStack;
|
||||
var otherSet, otherIter, otherValueIt, otherValue, otherStack;
|
||||
var baseValues, baseValue, baseStack;
|
||||
var otherValues, otherValue, otherStack;
|
||||
var found;
|
||||
var prevStackSize;
|
||||
for (i = 0; result && i < setPairs.length; i++) {
|
||||
baseIter = setPairs[i][0].values();
|
||||
otherSet = setPairs[i][1];
|
||||
baseValues = setPairs[i][0];
|
||||
otherValues = setPairs[i][1];
|
||||
baseStack = stackPairs[i][0];
|
||||
otherStack = stackPairs[i][1];
|
||||
// For each value in the base set...
|
||||
baseValueIt = baseIter.next();
|
||||
while (result && !baseValueIt.done) {
|
||||
baseValue = baseValueIt.value;
|
||||
for (var k = 0; result && k < baseValues.length; k++) {
|
||||
baseValue = baseValues[k];
|
||||
found = false;
|
||||
// ... test that it is present in the other set
|
||||
// Optimisation: start looking for value by object identity
|
||||
found = otherSet.has(baseValue);
|
||||
if (!found) {
|
||||
otherIter = otherSet.values();
|
||||
otherValueIt = otherIter.next();
|
||||
}
|
||||
// If not found, compare by value equality
|
||||
while (!found && !otherValueIt.done) {
|
||||
otherValue = otherValueIt.value;
|
||||
for (var l = 0; !found && l < otherValues.length; l++) {
|
||||
otherValue = otherValues[l];
|
||||
prevStackSize = baseStack.length;
|
||||
// compare by value equality
|
||||
found = eq(baseValue, otherValue, baseStack, otherStack, customTesters, j$.NullDiffBuilder());
|
||||
if (!found && prevStackSize !== baseStack.length) {
|
||||
baseStack.splice(prevStackSize);
|
||||
otherStack.splice(prevStackSize);
|
||||
}
|
||||
otherValueIt = otherIter.next();
|
||||
}
|
||||
result = result && found;
|
||||
baseValueIt = baseIter.next();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user