| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0e53c48 commit 6a61bcd
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -645,8 +645,10 @@ function setObjectEquiv(array, a, b, mode, memo) { | |||
| 645 | 645 | if (b.has(val1)) { | |
| 646 | 646 | continue; | |
| 647 | 647 | } | |
| 648 | - } else if (mode !== kLoose || b.has(val1)) { | ||
| 648 | + } else if (b.has(val1)) { | ||
| 649 | 649 | continue; | |
| 650 | + } else if (mode !== kLoose) { | ||
| 651 | + return false; | ||
| 650 | 652 | } | |
| 651 | 653 | } | |
| 652 | 654 | ||
@@ -792,11 +794,14 @@ function mapObjectEquiv(array, a, b, mode, memo) { | |||
| 792 | 794 | const extraChecks = mode === kLoose || array.length !== a.size; | |
| 793 | 795 | ||
| 794 | 796 | for (const { 0: key1, 1: item1 } of a) { | |
| 795 | - if (extraChecks && | ||
| 796 | - (typeof key1 !== 'object' || key1 === null) && | ||
| 797 | - (mode !== kLoose || | ||
| 798 | - (b.has(key1) && innerDeepEqual(item1, b.get(key1), mode, memo)))) { // Mixed mode | ||
| 799 | - continue; | ||
| 797 | + if (extraChecks && (typeof key1 !== 'object' || key1 === null)) { | ||
| 798 | + if (b.has(key1)) { | ||
| 799 | + if (mode !== kLoose || innerDeepEqual(item1, b.get(key1), mode, memo)) { | ||
| 800 | + continue; | ||
| 801 | + } | ||
| 802 | + } else if (mode !== kLoose) { | ||
| 803 | + return false; | ||
| 804 | + } | ||
| 800 | 805 | } | |
| 801 | 806 | ||
| 802 | 807 | let innerStart = start; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -634,6 +634,21 @@ test('Handle sparse arrays', () => { | |||
| 634 | 634 | assertNotDeepOrStrict(a, b, AssertionError, { partial: 'pass' }); | |
| 635 | 635 | }); | |
| 636 | 636 | ||
| 637 | + test('Handle sets and maps with mixed keys', () => { | ||
| 638 | + // https://github.com/nodejs/node/issues/61386 | ||
| 639 | + const aSet = new Set([0, new Set([1, 2, 3]), new Set([4, 5, 6])]); | ||
| 640 | + const bSet = new Set([ | ||
| 641 | + 0, | ||
| 642 | + new Set([1, new Set([2, 3]), new Set([20, 30])]), | ||
| 643 | + new Set([4, new Set([5, 6]), new Set([50, 60])]), | ||
| 644 | + ]); | ||
| 645 | + assertNotDeepOrStrict(aSet, bSet); | ||
| 646 | + | ||
| 647 | + const aMap = new Map([[0, 'zero'], [1, 'one'], [new Set([1, 2, 3]), 'A']]); | ||
| 648 | + const bMap = new Map([[0, 'zero'], [new Set([1, 2, 3]), 'A'], [new Set([9]), 'B']]); | ||
| 649 | + assertNotDeepOrStrict(aMap, bMap); | ||
| 650 | + }); | ||
| 651 | + | ||
| 637 | 652 | test('Handle different error messages', () => { | |
| 638 | 653 | const err1 = new Error('foo1'); | |
| 639 | 654 | assertNotDeepOrStrict(err1, new Error('foo2'), assert.AssertionError); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments