mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-14 20:57:49 +00:00
Ensure customizer results are respected by _.isEqual.
This commit is contained in:
@@ -3928,7 +3928,10 @@
|
|||||||
othValue = other[index],
|
othValue = other[index],
|
||||||
result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined;
|
result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined;
|
||||||
|
|
||||||
if (result !== undefined && !result) {
|
if (result !== undefined) {
|
||||||
|
if (result) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Recursively compare arrays (susceptible to call stack limits).
|
// Recursively compare arrays (susceptible to call stack limits).
|
||||||
|
|||||||
19
test/test.js
19
test/test.js
@@ -7749,15 +7749,26 @@
|
|||||||
strictEqual(_.isEqual('a', 'a', _.noop), true);
|
strictEqual(_.isEqual('a', 'a', _.noop), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should not handle comparisons if `customizer` returns `true`', 3, function() {
|
||||||
|
var customizer = function(value) {
|
||||||
|
return _.isString(value) || undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
strictEqual(_.isEqual('a', 'b', customizer), true);
|
||||||
|
strictEqual(_.isEqual(['a'], ['b'], customizer), true);
|
||||||
|
strictEqual(_.isEqual({ '0': 'a' }, { '0': 'b' }, customizer), true);
|
||||||
|
});
|
||||||
|
|
||||||
test('should return a boolean value even if `customizer` does not', 2, function() {
|
test('should return a boolean value even if `customizer` does not', 2, function() {
|
||||||
var actual = _.isEqual('a', 'a', _.constant('a'));
|
var actual = _.isEqual('a', 'b', _.constant('c'));
|
||||||
strictEqual(actual, true);
|
strictEqual(actual, true);
|
||||||
|
|
||||||
var expected = _.map(falsey, _.constant(false));
|
var values = _.without(falsey, undefined),
|
||||||
|
expected = _.map(values, _.constant(false));
|
||||||
|
|
||||||
actual = [];
|
actual = [];
|
||||||
_.each(falsey, function(value) {
|
_.each(values, function(value) {
|
||||||
actual.push(_.isEqual('a', 'b', _.constant(value)));
|
actual.push(_.isEqual('a', 'a', _.constant(value)));
|
||||||
});
|
});
|
||||||
|
|
||||||
deepEqual(actual, expected);
|
deepEqual(actual, expected);
|
||||||
|
|||||||
Reference in New Issue
Block a user