mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
Ensure _.isEqual works with maps and sets with circular references.
This commit is contained in:
40
test/test.js
40
test/test.js
@@ -9090,6 +9090,26 @@
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test('should compare maps with circular references', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
if (Map) {
|
||||
var map1 = new Map,
|
||||
map2 = new Map;
|
||||
|
||||
map1.set('a', map1);
|
||||
map2.set('a', map2);
|
||||
assert.strictEqual(_.isEqual(map1, map2), true);
|
||||
|
||||
map1.set('b', 1);
|
||||
map2.set('b', 2);
|
||||
assert.strictEqual(_.isEqual(map1, map2), false);
|
||||
}
|
||||
else {
|
||||
skipAssert(assert, 2);
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test('should compare regexes', function(assert) {
|
||||
assert.expect(5);
|
||||
|
||||
@@ -9127,6 +9147,26 @@
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test('should compare sets with circular references', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
if (Set) {
|
||||
var set1 = new Set,
|
||||
set2 = new Set;
|
||||
|
||||
set1.add(set1);
|
||||
set2.add(set2);
|
||||
assert.strictEqual(_.isEqual(set1, set2), true);
|
||||
|
||||
set1.add(1);
|
||||
set2.add(2);
|
||||
assert.strictEqual(_.isEqual(set1, set2), false);
|
||||
}
|
||||
else {
|
||||
skipAssert(assert, 2);
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test('should compare typed arrays', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user