| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4844fa2 commit e222e36
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -95,6 +95,7 @@ const CallTracker = require('internal/assert/calltracker'); | |||
| 95 | 95 | const { | |
| 96 | 96 | validateFunction, | |
| 97 | 97 | } = require('internal/validators'); | |
| 98 | + const { isURL } = require('internal/url'); | ||
| 98 | 99 | ||
| 99 | 100 | let isDeepEqual; | |
| 100 | 101 | let isDeepStrictEqual; | |
@@ -383,7 +384,7 @@ function isSpecial(obj) { | |||
| 383 | 384 | } | |
| 384 | 385 | ||
| 385 | 386 | const typesToCallDeepStrictEqualWith = [ | |
| 386 | - isKeyObject, isWeakSet, isWeakMap, Buffer.isBuffer, isSharedArrayBuffer, | ||
| 387 | + isKeyObject, isWeakSet, isWeakMap, Buffer.isBuffer, isSharedArrayBuffer, isURL, | ||
| 387 | 388 | ]; | |
| 388 | 389 | ||
| 389 | 390 | function partiallyCompareMaps(actual, expected, comparedObjects) { | |
@@ -466,7 +467,7 @@ function partiallyCompareArrayBuffersOrViews(actual, expected) { | |||
| 466 | 467 | } | |
| 467 | 468 | ||
| 468 | 469 | for (let i = 0; i < expectedViewLength; i++) { | |
| 469 | - if (actualView[i] !== expectedView[i]) { | ||
| 470 | + if (!ObjectIs(actualView[i], expectedView[i])) { | ||
| 470 | 471 | return false; | |
| 471 | 472 | } | |
| 472 | 473 | } | |
@@ -586,6 +587,10 @@ function compareBranch( | |||
| 586 | 587 | expected, | |
| 587 | 588 | comparedObjects, | |
| 588 | 589 | ) { | |
| 590 | + // Checking for the simplest case possible. | ||
| 591 | + if (actual === expected) { | ||
| 592 | + return true; | ||
| 593 | + } | ||
| 589 | 594 | // Check for Map object equality | |
| 590 | 595 | if (isMap(actual) && isMap(expected)) { | |
| 591 | 596 | return partiallyCompareMaps(actual, expected, comparedObjects); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -296,6 +296,16 @@ describe('Object Comparison Tests', () => { | |||
| 296 | 296 | actual: { dataView: new Uint8Array(3) }, | |
| 297 | 297 | expected: { dataView: new DataView(new ArrayBuffer(3)) }, | |
| 298 | 298 | }, | |
| 299 | + { | ||
| 300 | + description: 'throws when comparing Float32Array([+0.0]) with Float32Array([-0.0])', | ||
| 301 | + actual: new Float32Array([+0.0]), | ||
| 302 | + expected: new Float32Array([-0.0]), | ||
| 303 | + }, | ||
| 304 | + { | ||
| 305 | + description: 'throws when comparing two different urls', | ||
| 306 | + actual: new URL('http://foo'), | ||
| 307 | + expected: new URL('http://bar'), | ||
| 308 | + }, | ||
| 299 | 309 | { | |
| 300 | 310 | description: 'throws when comparing SharedArrayBuffers when expected has different elements actual', | |
| 301 | 311 | actual: (() => { | |
@@ -768,6 +778,21 @@ describe('Object Comparison Tests', () => { | |||
| 768 | 778 | actual: [1, 2, 3], | |
| 769 | 779 | expected: [2], | |
| 770 | 780 | }, | |
| 781 | + { | ||
| 782 | + description: 'ensures that File extends Blob', | ||
| 783 | + actual: Object.getPrototypeOf(File.prototype), | ||
| 784 | + expected: Blob.prototype | ||
| 785 | + }, | ||
| 786 | + { | ||
| 787 | + description: 'compares NaN with NaN', | ||
| 788 | + actual: NaN, | ||
| 789 | + expected: NaN, | ||
| 790 | + }, | ||
| 791 | + { | ||
| 792 | + description: 'compares two identical urls', | ||
| 793 | + actual: new URL('http://foo'), | ||
| 794 | + expected: new URL('http://foo'), | ||
| 795 | + }, | ||
| 771 | 796 | ].forEach(({ description, actual, expected }) => { | |
| 772 | 797 | it(description, () => { | |
| 773 | 798 | assert.partialDeepStrictEqual(actual, expected); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -101,10 +101,15 @@ suite('notEqualArrayPairs', () => { | |||
| 101 | 101 | makeBlock(assert.deepStrictEqual, arrayPair[0], arrayPair[1]), | |
| 102 | 102 | assert.AssertionError | |
| 103 | 103 | ); | |
| 104 | + // TODO(puskin94): remove emitWarning override once the partialDeepStrictEqual method is not experimental anymore | ||
| 105 | + // Suppress warnings, necessary otherwise the tools/pseudo-tty.py runner will fail | ||
| 106 | + const originalEmitWarning = process.emitWarning; | ||
| 107 | + process.emitWarning = () => {}; | ||
| 104 | 108 | assert.throws( | |
| 105 | 109 | makeBlock(assert.partialDeepStrictEqual, arrayPair[0], arrayPair[1]), | |
| 106 | 110 | assert.AssertionError | |
| 107 | 111 | ); | |
| 112 | + process.emitWarning = originalEmitWarning; // Restore original process.emitWarning | ||
| 108 | 113 | }); | |
| 109 | 114 | } | |
| 110 | 115 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments