Removed deprecated custom matcher, matchersUtil, pp, etc interfaces
This commit is contained in:
committed by
Steve Gravrock
parent
66189d742b
commit
4b2a14f1f3
@@ -29,19 +29,9 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
* @since 2.0.0
|
||||
* @param {*} haystack The collection to search
|
||||
* @param {*} needle The value to search for
|
||||
* @param [customTesters] An array of custom equality testers. Deprecated.
|
||||
* As of 3.6 this parameter no longer needs to be passed. It will be removed in 4.0.
|
||||
* @returns {boolean} True if `needle` was found in `haystack`
|
||||
*/
|
||||
MatchersUtil.prototype.contains = function(haystack, needle, customTesters) {
|
||||
if (customTesters) {
|
||||
j$.getEnv().deprecatedOnceWithStack(
|
||||
'Passing custom equality testers ' +
|
||||
'to MatchersUtil#contains is deprecated. ' +
|
||||
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
|
||||
);
|
||||
}
|
||||
|
||||
MatchersUtil.prototype.contains = function(haystack, needle) {
|
||||
if (j$.isSet(haystack)) {
|
||||
return haystack.has(needle);
|
||||
}
|
||||
@@ -51,7 +41,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
(!!haystack && !haystack.indexOf)
|
||||
) {
|
||||
for (var i = 0; i < haystack.length; i++) {
|
||||
if (this.equals(haystack[i], needle, customTesters)) {
|
||||
if (this.equals(haystack[i], needle)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -95,19 +85,11 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
b,
|
||||
aStack,
|
||||
bStack,
|
||||
customTesters,
|
||||
diffBuilder
|
||||
) {
|
||||
if (j$.isFunction_(b.valuesForDiff_)) {
|
||||
var values = b.valuesForDiff_(a, this.pp);
|
||||
this.eq_(
|
||||
values.other,
|
||||
values.self,
|
||||
aStack,
|
||||
bStack,
|
||||
customTesters,
|
||||
diffBuilder
|
||||
);
|
||||
this.eq_(values.other, values.self, aStack, bStack, diffBuilder);
|
||||
} else {
|
||||
diffBuilder.recordMismatch();
|
||||
}
|
||||
@@ -118,22 +100,18 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
b,
|
||||
aStack,
|
||||
bStack,
|
||||
customTesters,
|
||||
diffBuilder
|
||||
) {
|
||||
var asymmetricA = j$.isAsymmetricEqualityTester_(a),
|
||||
asymmetricB = j$.isAsymmetricEqualityTester_(b),
|
||||
shim,
|
||||
result;
|
||||
|
||||
if (asymmetricA === asymmetricB) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
shim = j$.asymmetricEqualityTesterArgCompatShim(this, customTesters);
|
||||
|
||||
if (asymmetricA) {
|
||||
result = a.asymmetricMatch(b, shim);
|
||||
result = a.asymmetricMatch(b, this);
|
||||
if (!result) {
|
||||
diffBuilder.recordMismatch();
|
||||
}
|
||||
@@ -141,9 +119,9 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
}
|
||||
|
||||
if (asymmetricB) {
|
||||
result = b.asymmetricMatch(a, shim);
|
||||
result = b.asymmetricMatch(a, this);
|
||||
if (!result) {
|
||||
this.asymmetricDiff_(a, b, aStack, bStack, customTesters, diffBuilder);
|
||||
this.asymmetricDiff_(a, b, aStack, bStack, diffBuilder);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -156,58 +134,18 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
* @since 2.0.0
|
||||
* @param {*} a The first value to compare
|
||||
* @param {*} b The second value to compare
|
||||
* @param [customTesters] An array of custom equality testers. Deprecated.
|
||||
* As of 3.6 this parameter no longer needs to be passed. It will be removed in 4.0.
|
||||
* @returns {boolean} True if the values are equal
|
||||
*/
|
||||
MatchersUtil.prototype.equals = function(
|
||||
a,
|
||||
b,
|
||||
customTestersOrDiffBuilder,
|
||||
diffBuilderOrNothing
|
||||
) {
|
||||
var customTesters, diffBuilder;
|
||||
|
||||
if (isDiffBuilder(customTestersOrDiffBuilder)) {
|
||||
diffBuilder = customTestersOrDiffBuilder;
|
||||
} else {
|
||||
if (customTestersOrDiffBuilder) {
|
||||
j$.getEnv().deprecatedOnceWithStack(
|
||||
'Passing custom equality testers ' +
|
||||
'to MatchersUtil#equals is deprecated. ' +
|
||||
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
|
||||
);
|
||||
}
|
||||
|
||||
if (diffBuilderOrNothing) {
|
||||
j$.getEnv().deprecatedOnceWithStack(
|
||||
'Diff builder should be passed ' +
|
||||
'as the third argument to MatchersUtil#equals, not the fourth. ' +
|
||||
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
|
||||
);
|
||||
}
|
||||
|
||||
customTesters = customTestersOrDiffBuilder;
|
||||
diffBuilder = diffBuilderOrNothing;
|
||||
}
|
||||
|
||||
customTesters = customTesters || this.customTesters_;
|
||||
MatchersUtil.prototype.equals = function(a, b, diffBuilder) {
|
||||
diffBuilder = diffBuilder || j$.NullDiffBuilder();
|
||||
diffBuilder.setRoots(a, b);
|
||||
|
||||
return this.eq_(a, b, [], [], customTesters, diffBuilder);
|
||||
return this.eq_(a, b, [], [], diffBuilder);
|
||||
};
|
||||
|
||||
// Equality function lovingly adapted from isEqual in
|
||||
// [Underscore](http://underscorejs.org)
|
||||
MatchersUtil.prototype.eq_ = function(
|
||||
a,
|
||||
b,
|
||||
aStack,
|
||||
bStack,
|
||||
customTesters,
|
||||
diffBuilder
|
||||
) {
|
||||
MatchersUtil.prototype.eq_ = function(a, b, aStack, bStack, diffBuilder) {
|
||||
var result = true,
|
||||
self = this,
|
||||
i;
|
||||
@@ -217,15 +155,14 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
b,
|
||||
aStack,
|
||||
bStack,
|
||||
customTesters,
|
||||
diffBuilder
|
||||
);
|
||||
if (!j$.util.isUndefined(asymmetricResult)) {
|
||||
return asymmetricResult;
|
||||
}
|
||||
|
||||
for (i = 0; i < customTesters.length; i++) {
|
||||
var customTesterResult = customTesters[i](a, b);
|
||||
for (i = 0; i < this.customTesters_.length; i++) {
|
||||
var customTesterResult = this.customTesters_[i](a, b);
|
||||
if (!j$.util.isUndefined(customTesterResult)) {
|
||||
if (!customTesterResult) {
|
||||
diffBuilder.recordMismatch();
|
||||
@@ -301,7 +238,6 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
new Uint8Array(b), // eslint-disable-line compat/compat
|
||||
aStack,
|
||||
bStack,
|
||||
customTesters,
|
||||
diffBuilder
|
||||
);
|
||||
// RegExps are compared by their source patterns and flags.
|
||||
@@ -380,7 +316,6 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
i < bLength ? b[i] : void 0,
|
||||
aStack,
|
||||
bStack,
|
||||
customTesters,
|
||||
diffBuilder
|
||||
) && result;
|
||||
}
|
||||
@@ -425,14 +360,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
if (
|
||||
j$.isAsymmetricEqualityTester_(mapKey) ||
|
||||
(j$.isAsymmetricEqualityTester_(cmpKey) &&
|
||||
this.eq_(
|
||||
mapKey,
|
||||
cmpKey,
|
||||
aStack,
|
||||
bStack,
|
||||
customTesters,
|
||||
j$.NullDiffBuilder()
|
||||
))
|
||||
this.eq_(mapKey, cmpKey, aStack, bStack, j$.NullDiffBuilder()))
|
||||
) {
|
||||
mapValueB = b.get(cmpKey);
|
||||
} else {
|
||||
@@ -443,7 +371,6 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
mapValueB,
|
||||
aStack,
|
||||
bStack,
|
||||
customTesters,
|
||||
j$.NullDiffBuilder()
|
||||
);
|
||||
}
|
||||
@@ -494,7 +421,6 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
otherValue,
|
||||
baseStack,
|
||||
otherStack,
|
||||
customTesters,
|
||||
j$.NullDiffBuilder()
|
||||
);
|
||||
if (!found && prevStackSize !== baseStack.length) {
|
||||
@@ -559,9 +485,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
}
|
||||
|
||||
diffBuilder.withPath(key, function() {
|
||||
if (
|
||||
!self.eq_(a[key], b[key], aStack, bStack, customTesters, diffBuilder)
|
||||
) {
|
||||
if (!self.eq_(a[key], b[key], aStack, bStack, diffBuilder)) {
|
||||
result = false;
|
||||
}
|
||||
});
|
||||
@@ -673,9 +597,5 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
return formatted;
|
||||
}
|
||||
|
||||
function isDiffBuilder(obj) {
|
||||
return obj && typeof obj.recordMismatch === 'function';
|
||||
}
|
||||
|
||||
return MatchersUtil;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user