mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
committed by
John-David Dalton
parent
94c3a8133c
commit
0cec225778
18
lodash.js
18
lodash.js
@@ -5634,10 +5634,11 @@
|
|||||||
if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
|
if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Assume cyclic values are equal.
|
// Check that cyclic values are equal.
|
||||||
var stacked = stack.get(array);
|
var arrStacked = stack.get(array);
|
||||||
if (stacked && stack.get(other)) {
|
var othStacked = stack.get(other);
|
||||||
return stacked == other;
|
if (arrStacked && othStacked) {
|
||||||
|
return arrStacked == other && othStacked == array;
|
||||||
}
|
}
|
||||||
var index = -1,
|
var index = -1,
|
||||||
result = true,
|
result = true,
|
||||||
@@ -5799,10 +5800,11 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Assume cyclic values are equal.
|
// Check that cyclic values are equal.
|
||||||
var stacked = stack.get(object);
|
var objStacked = stack.get(object);
|
||||||
if (stacked && stack.get(other)) {
|
var othStacked = stack.get(other);
|
||||||
return stacked == other;
|
if (objStacked && othStacked) {
|
||||||
|
return objStacked == other && othStacked == object;
|
||||||
}
|
}
|
||||||
var result = true;
|
var result = true;
|
||||||
stack.set(object, other);
|
stack.set(object, other);
|
||||||
|
|||||||
20
test/test.js
20
test/test.js
@@ -9741,7 +9741,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('should compare arrays with circular references', function(assert) {
|
QUnit.test('should compare arrays with circular references', function(assert) {
|
||||||
assert.expect(4);
|
assert.expect(6);
|
||||||
|
|
||||||
var array1 = [],
|
var array1 = [],
|
||||||
array2 = [];
|
array2 = [];
|
||||||
@@ -9766,6 +9766,14 @@
|
|||||||
array2 = ['a', ['a', 'b', 'c'], 'c'];
|
array2 = ['a', ['a', 'b', 'c'], 'c'];
|
||||||
|
|
||||||
assert.strictEqual(_.isEqual(array1, array2), false);
|
assert.strictEqual(_.isEqual(array1, array2), false);
|
||||||
|
|
||||||
|
array1 = [[[]]];
|
||||||
|
array1[0][0][0] = array1;
|
||||||
|
array2 = [];
|
||||||
|
array2[0] = array2;
|
||||||
|
|
||||||
|
assert.strictEqual(_.isEqual(array1, array2), false);
|
||||||
|
assert.strictEqual(_.isEqual(array2, array1), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('should have transitive equivalence for circular references of arrays', function(assert) {
|
QUnit.test('should have transitive equivalence for circular references of arrays', function(assert) {
|
||||||
@@ -9783,7 +9791,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('should compare objects with circular references', function(assert) {
|
QUnit.test('should compare objects with circular references', function(assert) {
|
||||||
assert.expect(4);
|
assert.expect(6);
|
||||||
|
|
||||||
var object1 = {},
|
var object1 = {},
|
||||||
object2 = {};
|
object2 = {};
|
||||||
@@ -9808,6 +9816,14 @@
|
|||||||
object2 = { 'a': 1, 'b': { 'a': 1, 'b': 2, 'c': 3 }, 'c': 3 };
|
object2 = { 'a': 1, 'b': { 'a': 1, 'b': 2, 'c': 3 }, 'c': 3 };
|
||||||
|
|
||||||
assert.strictEqual(_.isEqual(object1, object2), false);
|
assert.strictEqual(_.isEqual(object1, object2), false);
|
||||||
|
|
||||||
|
object1 = {self: {self: {self: {}}}};
|
||||||
|
object1.self.self.self = object1;
|
||||||
|
object2 = {self: {}};
|
||||||
|
object2.self = object2;
|
||||||
|
|
||||||
|
assert.strictEqual(_.isEqual(object1, object2), false);
|
||||||
|
assert.strictEqual(_.isEqual(object2, object1), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('should have transitive equivalence for circular references of objects', function(assert) {
|
QUnit.test('should have transitive equivalence for circular references of objects', function(assert) {
|
||||||
|
|||||||
Reference in New Issue
Block a user