Skip to content

Commit 5f42b1f

Browse files
ljharbMylesBorins
authored andcommitted
test: assert: fix deepStrictEqual comparing a real array and fake array
PR-URL: #30743 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent 9d1c793 commit 5f42b1f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/parallel/test-assert-deep.js

+15
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,21 @@ assert.throws(
10431043
assertDeepAndStrictEqual(a, b);
10441044
}
10451045

1046+
// Verify that an array and the equivalent fake array object
1047+
// are correctly compared
1048+
{
1049+
const a = [1, 2, 3];
1050+
const o = {
1051+
__proto__: Array.prototype,
1052+
0: 1,
1053+
1: 2,
1054+
2: 3,
1055+
length: 3,
1056+
};
1057+
Object.defineProperty(o, 'length', { enumerable: false });
1058+
assertNotDeepOrStrict(o, a);
1059+
}
1060+
10461061
// Verify that extra keys will be tested for when using fake arrays.
10471062
{
10481063
const a = {

0 commit comments

Comments
 (0)